1
- #!/usr/bin/env python2.7
1
+ #!/usr/bin/env python
2
2
"""Tool to filter, organize, compare and display benchmarking results. Usefull
3
3
for smaller datasets. It works great with a few dozen runs it is not designed to
4
4
deal with hundreds.
5
5
Requires the pandas library to be installed."""
6
+ from __future__ import print_function
7
+
6
8
import pandas as pd
7
9
import sys
8
10
import os .path
@@ -19,7 +21,7 @@ def read_lit_json(filename):
19
21
info_columns = ['hash' ]
20
22
# Pass1: Figure out metrics (= the column index)
21
23
if 'tests' not in jsondata :
22
- print "%s: Could not find toplevel 'tests' key"
24
+ print ( "%s: Could not find toplevel 'tests' key" )
23
25
sys .exit (1 )
24
26
for test in jsondata ['tests' ]:
25
27
name = test .get ("name" )
@@ -31,7 +33,7 @@ def read_lit_json(filename):
31
33
sys .exit (1 )
32
34
names .add (name )
33
35
if "metrics" not in test :
34
- print "Warning: '%s' has No metrics!" % test ['name' ]
36
+ print ( "Warning: '%s' has No metrics!" % test ['name' ])
35
37
continue
36
38
for name in test ["metrics" ].keys ():
37
39
if name not in columnindexes :
@@ -54,9 +56,9 @@ def read_lit_json(filename):
54
56
55
57
datarow = [nan ] * len (columns )
56
58
if "metrics" in test :
57
- for (metricname , value ) in test ['metrics' ].iteritems ():
59
+ for (metricname , value ) in test ['metrics' ].items ():
58
60
datarow [columnindexes [metricname ]] = value
59
- for (name , value ) in test .iteritems ():
61
+ for (name , value ) in test .items ():
60
62
index = columnindexes .get (name )
61
63
if index is not None :
62
64
datarow [index ] = test [name ]
@@ -148,7 +150,7 @@ def print_filter_stats(reason, before, after):
148
150
n_after = len (after .groupby (level = 1 ))
149
151
n_filtered = n_before - n_after
150
152
if n_filtered != 0 :
151
- print "%s: %s (filtered out)" % (reason , n_filtered )
153
+ print ( "%s: %s (filtered out)" % (reason , n_filtered ) )
152
154
153
155
# Truncate a string to a maximum length by keeping a prefix, a suffix and ...
154
156
# in the middle
@@ -222,8 +224,8 @@ def format_name(name, common_prefix, common_suffix):
222
224
pd .set_option ("display.max_colwidth" , 0 )
223
225
out = dataout .to_string (index = False , justify = 'left' ,
224
226
float_format = float_format , formatters = formatters )
225
- print out
226
- print d .describe ()
227
+ print ( out )
228
+ print ( d .describe () )
227
229
228
230
if __name__ == "__main__" :
229
231
parser = argparse .ArgumentParser (prog = 'compare.py' )
@@ -303,7 +305,7 @@ def format_name(name, common_prefix, common_suffix):
303
305
# Filter data
304
306
proggroup = data .groupby (level = 1 )
305
307
initial_size = len (proggroup .indices )
306
- print "Tests: %s" % (initial_size ,)
308
+ print ( "Tests: %s" % (initial_size ,) )
307
309
if config .filter_failed and hasattr (data , 'Exec' ):
308
310
newdata = filter_failed (data )
309
311
print_filter_stats ("Failed" , data , newdata )
@@ -326,10 +328,10 @@ def format_name(name, common_prefix, common_suffix):
326
328
data = newdata
327
329
final_size = len (data .groupby (level = 1 ))
328
330
if final_size != initial_size :
329
- print "Remaining: %d" % (final_size ,)
331
+ print ( "Remaining: %d" % (final_size ,) )
330
332
331
333
# Reduce / add columns
332
- print "Metric: %s" % ("," .join (metrics ),)
334
+ print ( "Metric: %s" % ("," .join (metrics ),) )
333
335
if len (metrics ) > 0 :
334
336
data = data [metrics ]
335
337
data = add_diff_column (data )
@@ -339,7 +341,7 @@ def format_name(name, common_prefix, common_suffix):
339
341
sortkey = data .columns [0 ]
340
342
341
343
# Print data
342
- print ""
344
+ print ( "" )
343
345
shorten_names = not config .full
344
346
limit_output = (not config .all ) and (not config .full )
345
347
print_result (data , limit_output , shorten_names , config .show_diff , sortkey )
0 commit comments