1- #!/usr/bin/env python2.7  
1+ #!/usr/bin/env python  
22"""Tool to filter, organize, compare and display benchmarking results. Usefull 
33for smaller datasets. It works great with a few dozen runs it is not designed to 
44deal with hundreds. 
55Requires the pandas library to be installed.""" 
6+ from  __future__ import  print_function 
7+ 
68import  pandas  as  pd 
79import  sys 
810import  os .path 
@@ -19,7 +21,7 @@ def read_lit_json(filename):
1921 info_columns  =  ['hash' ]
2022 # Pass1: Figure out metrics (= the column index) 
2123 if  'tests'  not  in jsondata :
22-  print   "%s: Could not find toplevel 'tests' key" 
24+  print ( "%s: Could not find toplevel 'tests' key" ) 
2325 sys .exit (1 )
2426 for  test  in  jsondata ['tests' ]:
2527 name  =  test .get ("name" )
@@ -31,7 +33,7 @@ def read_lit_json(filename):
3133 sys .exit (1 )
3234 names .add (name )
3335 if  "metrics"  not  in test :
34-  print   "Warning: '%s' has No metrics!"  %  test ['name' ]
36+  print ( "Warning: '%s' has No metrics!"  %  test ['name' ]) 
3537 continue 
3638 for  name  in  test ["metrics" ].keys ():
3739 if  name  not  in columnindexes :
@@ -54,9 +56,9 @@ def read_lit_json(filename):
5456
5557 datarow  =  [nan ] *  len (columns )
5658 if  "metrics"  in  test :
57-  for  (metricname , value ) in  test ['metrics' ].iteritems ():
59+  for  (metricname , value ) in  test ['metrics' ].items ():
5860 datarow [columnindexes [metricname ]] =  value 
59-  for  (name , value ) in  test .iteritems ():
61+  for  (name , value ) in  test .items ():
6062 index  =  columnindexes .get (name )
6163 if  index  is  not None :
6264 datarow [index ] =  test [name ]
@@ -148,7 +150,7 @@ def print_filter_stats(reason, before, after):
148150 n_after  =  len (after .groupby (level = 1 ))
149151 n_filtered  =  n_before  -  n_after 
150152 if  n_filtered  !=  0 :
151-  print   "%s: %s (filtered out)"  %  (reason , n_filtered )
153+  print ( "%s: %s (filtered out)"  %  (reason , n_filtered ) )
152154
153155# Truncate a string to a maximum length by keeping a prefix, a suffix and ... 
154156# in the middle 
@@ -222,8 +224,8 @@ def format_name(name, common_prefix, common_suffix):
222224 pd .set_option ("display.max_colwidth" , 0 )
223225 out  =  dataout .to_string (index = False , justify = 'left' ,
224226 float_format = float_format , formatters = formatters )
225-  print   out 
226-  print   d .describe ()
227+  print ( out ) 
228+  print ( d .describe () )
227229
228230if  __name__  ==  "__main__" :
229231 parser  =  argparse .ArgumentParser (prog = 'compare.py' )
@@ -303,7 +305,7 @@ def format_name(name, common_prefix, common_suffix):
303305 # Filter data 
304306 proggroup  =  data .groupby (level = 1 )
305307 initial_size  =  len (proggroup .indices )
306-  print   "Tests: %s"  %  (initial_size ,)
308+  print ( "Tests: %s"  %  (initial_size ,) )
307309 if  config .filter_failed  and  hasattr (data , 'Exec' ):
308310 newdata  =  filter_failed (data )
309311 print_filter_stats ("Failed" , data , newdata )
@@ -326,10 +328,10 @@ def format_name(name, common_prefix, common_suffix):
326328 data  =  newdata 
327329 final_size  =  len (data .groupby (level = 1 ))
328330 if  final_size  !=  initial_size :
329-  print   "Remaining: %d"  %  (final_size ,)
331+  print ( "Remaining: %d"  %  (final_size ,) )
330332
331333 # Reduce / add columns 
332-  print   "Metric: %s"  %  ("," .join (metrics ),)
334+  print ( "Metric: %s"  %  ("," .join (metrics ),) )
333335 if  len (metrics ) >  0 :
334336 data  =  data [metrics ]
335337 data  =  add_diff_column (data )
@@ -339,7 +341,7 @@ def format_name(name, common_prefix, common_suffix):
339341 sortkey  =  data .columns [0 ]
340342
341343 # Print data 
342-  print   "" 
344+  print ( "" ) 
343345 shorten_names  =  not  config .full 
344346 limit_output  =  (not  config .all ) and  (not  config .full )
345347 print_result (data , limit_output , shorten_names , config .show_diff , sortkey )
0 commit comments