about summary refs log tree commit diff homepage
path: root/tools/klee-stats
diff options
context:
space:
mode:
authorGeorge Ordish <george.ordish17@imperial.ac.uk>2019-08-05 11:48:22 +0100
committerCristian Cadar <c.cadar@imperial.ac.uk>2019-08-08 10:45:58 +0100
commitf9aa2a3534ac47e07cd1f8b21bafb784b7a0c6c6 (patch)
tree185054f7d51358877555420729d2a1539dd5a443 /tools/klee-stats
parent04f5031ce572fa7488c9d97155207a3f5832e212 (diff)
downloadklee-f9aa2a3534ac47e07cd1f8b21bafb784b7a0c6c6.tar.gz
Read Klee's start time correctly in klee-stats
The last modification time of the run.stats database was being used as
the starting time of klee. This was causing Grafana to show graphs
incorrectly.

Instead we now read the start time from the info file.

Co-Authored-By: Kenny Macheka <knm17@ic.ac.uk>
Diffstat (limited to 'tools/klee-stats')
-rwxr-xr-xtools/klee-stats/klee-stats19
1 files changed, 18 insertions, 1 deletions
diff --git a/tools/klee-stats/klee-stats b/tools/klee-stats/klee-stats
index 6fcf97c6..864e8993 100755
--- a/tools/klee-stats/klee-stats
+++ b/tools/klee-stats/klee-stats
@@ -53,6 +53,10 @@ KleeTable = TableFormat(lineabove=Line("-", "-", "-", "-"),
                         padding=0,
                         with_header_hide=None)
 
+def getInfoFile(path):
+    """Return the path to info"""
+    return os.path.join(path, 'info')
+
 def getLogFile(path):
     """Return the path to run.stats."""
     return os.path.join(path, 'run.stats')
@@ -167,6 +171,19 @@ def grafana(dirs):
     import datetime
     app = Flask(__name__)
 
+    import re
+    from dateutil import parser
+    def getKleeStartTime():
+        with open(getInfoFile(dirs[0]), "r") as file:
+            for line in file:
+                m = re.match("Started: (.*)", line)
+                if m:
+                    dateString = m.group(1)
+                    return parser.parse(dateString).timestamp()
+
+        print("Error: Couldn't find klee's start time", file=sys.stderr)
+        sys.exit()
+
     def toEpoch(date_text):
         dt = datetime.datetime.strptime(date_text, "%Y-%m-%dT%H:%M:%S.%fZ")
         epoch = (dt - datetime.datetime(1970, 1, 1)).total_seconds()
@@ -191,7 +208,7 @@ def grafana(dirs):
         frm = toEpoch(jsn["range"]["from"])
         to = toEpoch(jsn["range"]["to"])
         targets = [str(t["target"]) for t in jsn["targets"]]
-        startTime = os.path.getmtime(dr)
+        startTime = getKleeStartTime()
         fromTime = frm - startTime if frm - startTime > 0 else 0
         toTime = to - startTime if to - startTime > fromTime else fromTime + 100
         #convert to microseconds