minor changes to time formats in TRexDataAnalysis Script: added the time format of... 61/5261/1
authoritraviv <[email protected]>
Thu, 19 Jan 2017 07:39:51 +0000 (09:39 +0200)
committeritraviv <[email protected]>
Thu, 19 Jan 2017 07:40:04 +0000 (09:40 +0200)
Signed-off-by: itraviv <[email protected]>
doc/TRexDataAnalysisV2.py

index e57b701..1914319 100755 (executable)
@@ -28,14 +28,15 @@ This Module is structured to work with a raw data at the following JSON format:
 \r
  ["syn attack - 64 bytes, single CPU", "stl", "20161226", "01", "39", "9.631898", "9.5", "11.5", "54289"]\r
 \r
- it can be changed to support other formats of queries, simply change the enum class to support your desired structure\r
- the enums specify the indexes of the data within the query tuple\r
+ it can be changed to support other formats of queries, simply change the query class to support your desired structure\r
+ the query class specify the indexes of the data within the query tuple\r
 \r
 """\r
 \r
 \r
 class TestQuery(object):\r
-    QUERY_DATE = 2  # date format is yyyymmdd\r
+    query_dateformat = "%Y%m%d"  # date format in the query\r
+    QUERY_DATE = 2\r
     QUERY_HOUR = 3\r
     QUERY_MINUTE = 4\r
     QUERY_MPPS_RESULT = 5\r
@@ -61,7 +62,8 @@ class Test:
         test_mins = set()\r
         test_maxs = set()\r
         for query in raw_test_data:\r
-            date_formatted = time.strftime("%d-%m-%Y", time.strptime(query[int(TestQuery.QUERY_DATE)], "%Y%m%d"))\r
+            date_formatted = time.strftime("%d-%m-%Y",\r
+                                           time.strptime(query[int(TestQuery.QUERY_DATE)], TestQuery.query_dateformat))\r
             time_of_res = date_formatted + '-' + query[int(TestQuery.QUERY_HOUR)] + ':' + query[\r
                 int(TestQuery.QUERY_MINUTE)]\r
             test_dates.append(time_of_res)\r
@@ -133,14 +135,14 @@ class Setup:
         for test in self.tests:\r
             test_data = test.results_df[test.results_df.columns[2]].tolist()\r
             test_time_stamps = test.results_df[test.results_df.columns[3]].tolist()\r
-            test_time_stamps.append(self.end_date+'-23:59')\r
+            test_time_stamps.append(self.end_date + '-23:59')\r
             test_data.append(test_data[-1])\r
             float_test_time_stamps = []\r
             for ts in test_time_stamps:\r
                 try:\r
-                   float_test_time_stamps.append(matdates.date2num(datetime.strptime(ts, time_format1)))\r
+                    float_test_time_stamps.append(matdates.date2num(datetime.strptime(ts, time_format1)))\r
                 except:\r
-                   float_test_time_stamps.append(matdates.date2num(datetime.strptime(ts, time_format2)))\r
+                    float_test_time_stamps.append(matdates.date2num(datetime.strptime(ts, time_format2)))\r
             plt.plot_date(x=float_test_time_stamps, y=test_data, label=test.name, fmt='-', xdate=True)\r
             plt.legend(fontsize='small', loc='best')\r
         plt.ylabel('MPPS/Core (Norm)')\r