[PATCH] run-tests: added '--graph' functionality to store timing data in json file
Anurag Goel
anurag.dsps at gmail.com
Mon Jun 16 14:55:02 CDT 2014
# HG changeset patch
# User anuraggoel <anurag.dsps at gmail.com>
# Date 1402941179 -19800
# Mon Jun 16 23:22:59 2014 +0530
# Node ID c3dacef6c7c12ec1f3a0879af4a28dd72e4ac53b
# Parent 477bc39f2d88a7d38127a3509d3d85cc9b62faee
run-tests: added '--graph' functionality to store timing data in json file
This patch added a new functionality '--graph'. While testing, if '--graph'
is enabled then timing data gets stored in newly created "report.json" file,
in the format of "testname : testtime".
This "report.json" file will further accessed by html/javascript file to
plot graph between testname Vs testime.
diff -r 477bc39f2d88 -r c3dacef6c7c1 tests/run-tests.py
--- a/tests/run-tests.py Fri Jun 13 14:45:23 2014 +0530
+++ b/tests/run-tests.py Mon Jun 16 23:22:59 2014 +0530
@@ -58,6 +58,7 @@
import killdaemons as killmod
import Queue as queue
import unittest
+import json
processlock = threading.Lock()
@@ -185,6 +186,8 @@
" (default: $%s or %d)" % defaults['timeout'])
parser.add_option("--time", action="store_true",
help="time how long each test takes")
+ parser.add_option("--graph", action="store_true",
+ help="store timing data in 'report.json' file")
parser.add_option("--tmpdir", type="string",
help="run tests in the given temporary directory"
" (implies --keep-tmpdir)")
@@ -1335,6 +1338,14 @@
os.environ['PYTHONHASHSEED'])
if self._runner.options.time:
self.printtimes(result.times)
+ if self._runner.options.graph:
+ self.getgraph(result.times)
+
+ def getgraph(self, times):
+ fp = open("report.json", "w")
+ fp.writelines(("testreport =", (json.dumps({item[0]:item[1] for item in
+ times}, indent=2))))
+ fp.close()
def printtimes(self, times):
self.stream.writeln('# Producing time report')
More information about the Mercurial-devel
mailing list