about summary refs log tree commit diff homepage
path: root/tools
diff options
context:
space:
mode:
authorTimotej Kapus <tk1713@ic.ac.uk>2019-04-07 12:57:27 +0100
committerMartinNowack <martin.nowack@gmail.com>2019-04-12 10:41:28 +0100
commitff922213fd9fef1ceb09a22aa65720e275dfcdea (patch)
treeea2a9648435f8efec31a327190a9f007c77a535a /tools
parent9df5fe2f0d436923bae81e67ae0b42bdc298d0c0 (diff)
downloadklee-ff922213fd9fef1ceb09a22aa65720e275dfcdea.tar.gz
Fix handling of time in grafana
Diffstat (limited to 'tools')
-rwxr-xr-xtools/klee-stats/klee-stats7
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/klee-stats/klee-stats b/tools/klee-stats/klee-stats
index 2aafb1fa..6fcf97c6 100755
--- a/tools/klee-stats/klee-stats
+++ b/tools/klee-stats/klee-stats
@@ -194,6 +194,8 @@ def grafana(dirs):
         startTime = os.path.getmtime(dr)
         fromTime = frm - startTime if frm - startTime > 0 else 0
         toTime = to - startTime if to - startTime > fromTime else fromTime + 100
+        #convert to microseconds
+        startTime, fromTime, toTime = startTime*1000000, fromTime*1000000, toTime*1000000
         sqlTarget = ",".join(["AVG( {0} )".format(t) for t in targets if t.isalnum()])
 
         conn = sqlite3.connect(dr)
@@ -204,10 +206,11 @@ def grafana(dirs):
             + " GROUP BY WallTime/? LIMIT ?"
         s = s.format(fields=sqlTarget) #can't use prepared staments for this one
 
-        cursor = conn.execute(s, ( startTime, fromTime, toTime, interval/1000, limit))
+        #All times need to be in microseconds, interval is in milliseconds
+        cursor = conn.execute(s, ( startTime, fromTime, toTime, interval*1000, limit))
         result = [ {"target": t, "datapoints": []} for t in targets ]
         for line in cursor:
-            unixtimestamp = int(line[0]) * 1000  #miliseconds
+            unixtimestamp = int(line[0]) / 1000 #Convert from microsecond to miliseconds
             for field, datastream in zip(line[1:], result):
                 datastream["datapoints"].append([field, unixtimestamp])