[Tizen.Net] add inserting memory usage data of apps. 88/133988/1
authorjang <jiseob.jang@samsung.com>
Wed, 14 Jun 2017 06:34:16 +0000 (15:34 +0900)
committerjang <jiseob.jang@samsung.com>
Wed, 14 Jun 2017 06:34:16 +0000 (15:34 +0900)
Change-Id: Ifd845505fce0ec1c0f5cd7b9200cce75cc8c8ef4
Signed-off-by: jang <jiseob.jang@samsung.com>
job_add_dotnet_launching_performance_test.py

index 478a019..eb89250 100644 (file)
@@ -70,22 +70,24 @@ def main():
     CONFIG['MYSQL']['database'] = os.getenv("BUILDMONITOR_NAME")
     print '[CONFIG] mysql - load getenv.\n'
 
+    print CONFIG
+
+
     test_data = os.getenv('file0')
 
     if test_data:
-        f = open( 'file0', 'r')
+        f = open('file0', 'r')
         TEST_DATA = unicode_to_str(json.loads(f.read()))
         f.close()
     else:
         sys.exit( "[Error] TRBS_DATA is empty!\n" )
 
-    print '[TEST_DATA] load TRBS_DATA.\n'
+    print '[TEST_DATA] load TEST_DATA.\n'
 
 
     print '===========[ TEST DATA ]===========\n'
     print TEST_DATA
 
-
     # Connect MySQL
     MYSQL['connection'] = MySQLdb.connect( host  =CONFIG['MYSQL']['host'],
                                            user  =CONFIG['MYSQL']['user'],
@@ -140,7 +142,7 @@ def main():
         MYSQL['query']['insert_application_info'] = "INSERT INTO application_info (name, app_id, pkg_id, app_type) SELECT '%s', '%s', '%s', '%s' FROM DUAL WHERE NOT EXISTS ( SELECT * FROM application_info WHERE app_id='%s' AND pkg_id='%s' );" % (pkg_id, app_id, pkg_id, app_type, app_id, pkg_id)
         mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['insert_application_info'])
 
-    # get launching_performance_test_id    
+    # get launching_performance_test_id
 #    MYSQL['query']['select_launching_performance_test'] = "SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_name = 'launching_performance_test' AND table_schema = DATABASE( ) ;"
 #    mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['select_launching_performance_test'])
 #    launching_performance_test_id = MYSQL['cursor'].fetchone()['AUTO_INCREMENT']
@@ -151,8 +153,8 @@ def main():
     MYSQL['query']['insert_launching_performance_test'] = "INSERT INTO launching_performance_test (build_image_id, average_time, test_date) SELECT %s, %s, FROM_UNIXTIME(UNIX_TIMESTAMP()) FROM DUAL WHERE NOT EXISTS ( SELECT * FROM launching_performance_test WHERE build_image_id=%s AND average_time=%s );" % (build_image_id, average_time, build_image_id, average_time)
 #    MYSQL['query']['insert_launching_performance_test'] = "INSERT INTO launching_performance_test (build_image_id, average_time, test_date) VALUES (%s, %s, FROM_UNIXTIME(UNIX_TIMESTAMP()) );" % (build_image_id, average_time)
     mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['insert_launching_performance_test'])
-    
-    # get launching_performance_test_id    
+
+    # get launching_performance_test_id
     MYSQL['query']['select_launching_performance_test'] = "SELECT id FROM launching_performance_test WHERE build_image_id=%s AND average_time=%s;" % (build_image_id, average_time)
     mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['select_launching_performance_test'])
     launching_performance_test_id = MYSQL['cursor'].fetchone()['id']
@@ -168,7 +170,7 @@ def main():
         app_info_ids[row['app_id']] = row['id']
         row = MYSQL['cursor'].fetchone()
     print 'app_info_ids: ', app_info_ids
-        
+
 
     launching_performance_list = TEST_DATA['launching_performance']
     for launching_performance in launching_performance_list:
@@ -181,9 +183,58 @@ def main():
 #        application_info_id = MYSQL['cursor'].fetchone()['id']
 #        print "[Write] application_info id =", application_info_id
 
-        MYSQL['query']['insert_launching_performance'] =  "INSERT INTO launching_performance (launching_performance_test_id, build_image_id, application_info_id, launching_time) VALUES (%s, %s, %s, %s);" % (launching_performance_test_id, build_image_id, application_info_id, launching_time)
+        MYSQL['query']['insert_launching_performance'] = "INSERT INTO launching_performance (launching_performance_test_id, build_image_id, application_info_id, launching_time) SELECT %s, %s, %s, %s FROM DUAL WHERE NOT EXISTS ( SELECT * FROM launching_performance WHERE launching_performance_test_id=%s AND application_info_id=%s );" % (launching_performance_test_id, build_image_id, application_info_id, launching_time, launching_performance_test_id, application_info_id)
+#        MYSQL['query']['insert_launching_performance'] =  "INSERT INTO launching_performance (launching_performance_test_id, build_image_id, application_info_id, launching_time) VALUES (%s, %s, %s, %s);" % (launching_performance_test_id, build_image_id, application_info_id, launching_time)
         mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['insert_launching_performance'])
-        
+
+    ### insert memory usage data ###
+    # get launching_memory_usage_test_id
+#    MYSQL['query']['select_launching_memory_usage_test'] = "SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_name = 'launching_memory_usage_test' AND table_schema = DATABASE( ) ;"
+#    mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['select_launching_memory_usage_test'])
+#    launching_memory_usage_test_id = MYSQL['cursor'].fetchone()['AUTO_INCREMENT']
+#    print "[Write] launching_memory_usage_test id =", launching_memory_usage_test_id
+
+    # insert launching_memory_usage_test
+    memory_usage_sum = TEST_DATA['memory_sum']
+    app_count = TEST_DATA['memory_count']
+    average_memory_usage = memory_usage_sum / app_count
+    MYSQL['query']['insert_launching_memory_usage_test'] = "INSERT INTO launching_memory_usage_test (build_image_id, average_memory_usage, memory_usage_sum, app_count, test_date) SELECT %s, %s, %s, %s, FROM_UNIXTIME(UNIX_TIMESTAMP()) FROM DUAL WHERE NOT EXISTS ( SELECT * FROM launching_memory_usage_test WHERE build_image_id=%s AND average_memory_usage=%s );" % (build_image_id, average_memory_usage, memory_usage_sum, app_count, build_image_id, average_memory_usage)
+    mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['insert_launching_memory_usage_test'])
+
+    # get launching_memory_usage_test_id
+    MYSQL['query']['select_launching_memory_usage_test'] = "SELECT id FROM launching_memory_usage_test WHERE build_image_id=%s AND average_memory_usage=%s;" % (build_image_id, average_memory_usage)
+    mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['select_launching_memory_usage_test'])
+    launching_memory_usage_test_id = MYSQL['cursor'].fetchone()['id']
+    print "[Write] launching_memory_usage_test id =", launching_memory_usage_test_id
+
+
+    # insert launching memory usage and insert launching memory object
+    launching_memory_list = TEST_DATA['memory_performance']
+    for launching_memory in launching_memory_list:
+        usage = launching_memory['usage']
+        pss = launching_memory['pss']
+        memory_3d = launching_memory['3d']
+        gem = launching_memory['gem']
+        app_id = launching_memory['app_id']
+        pkg_id = launching_memory['pkg_id']
+        application_info_id = app_info_ids[app_id]
+
+        MYSQL['query']['select_launching_memory_usage'] = "SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_name = 'launching_memory_usage' AND table_schema = DATABASE( ) ;"
+        mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['select_launching_memory_usage'])
+        launching_memory_usage_id = MYSQL['cursor'].fetchone()['AUTO_INCREMENT']
+
+        MYSQL['query']['insert_launching_memory_usage'] = "INSERT INTO launching_memory_usage (launching_memory_usage_test_id, build_image_id, application_info_id, memory_usage, pss, 3d, gem) SELECT %s, %s, %s, %s, %s, %s, %s FROM DUAL WHERE NOT EXISTS ( SELECT * FROM launching_memory_usage WHERE launching_memory_usage_test_id=%s AND application_info_id=%s );" % (launching_memory_usage_test_id, build_image_id, application_info_id, usage, pss, memory_3d, gem, launching_memory_usage_test_id, application_info_id)
+#        MYSQL['query']['insert_launching_memory_usage'] = "INSERT INTO launching_memory_usage (launching_memory_usage_test_id, build_image_id, application_info_id, memory_usage, pss, 3d, gem) VALUES (%s, %s, %s, %s, %s, %s, %s);" % (launching_memory_usage_test_id, build_image_id, application_info_id, usage, pss, memory_3d, gem)
+        mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['insert_launching_memory_usage'])
+
+        object_memory_list = launching_memory['app_memory_list']
+        for object_memory in object_memory_list:
+            object_name = object_memory['object_name']
+            pcode_pdata = object_memory['pcode_pdata']
+
+            MYSQL['query']['insert_launching_memory_object'] =  "INSERT INTO launching_memory_object (launching_memory_usage_test_id, launching_memory_usage_id, build_image_id, application_info_id, object_name, pcode_pdata) VALUES (%s, %s, %s, %s, '%s', %s);" % (launching_memory_usage_test_id, launching_memory_usage_id, build_image_id, application_info_id, object_name, pcode_pdata)
+            mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['insert_launching_memory_object'])
+
 
     MYSQL['cursor'].close()
     MYSQL['connection'].close()