Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
compare_times.py
Go to the documentation of this file.
1 #!/bin/env python
2 
3 def load_files():
4  import json
5  new=None
6  from os.path import exists
7  try:
8  new = json.load( open('_performance_') )
9  except:
10  print 'Missing "_performance_" file'
11  ref=None
12  try:
13  ref = json.load( open('_old_performance_') )
14  except:
15  print 'Missing "old_performance_" file'
16  return new, ref
17 
18 
20  new, ref = load_files()
21  runtimes_compare = open('runtime_diffs.txt', 'w')
22  format_string = '%7.1f %7.1f %7.1f %6.2f %s\n'
23  runtimes_compare.write('%7s %7s %7s %6s %s\n' % ("NEW", "REF", "DIFF", "D/R", "TEST"))
24 
25  from math import isnan, isinf
26  diffs=[]
27  new_values=[]
28  ref_values=[]
29  for key in set(new.keys() + ref.keys()):
30  if key in new and key in ref:
31  n = new[key]
32  r = ref[key]
33  if isnan(n+r) or isinf(n+r):
34  continue # cannot compare
35  diff = n -r
36  runtimes_compare.write( format_string % (n, r, diff, diff/r, key) )
37  diffs.append(diff)
38  new_values.append(n)
39  ref_values.append(r)
40  new_sum = sum(new_values)
41  ref_sum = sum(ref_values)
42  new_avg = new_sum/float(len(new_values))
43  ref_avg = ref_sum/float(len(ref_values))
44 
45  runtimes_compare.write( format_string % (new_sum, ref_sum, new_sum - ref_sum, (new_sum-ref_sum)/ref_sum, 'TOTAL' ))
46  runtimes_compare.write( format_string % (new_avg, ref_avg, new_avg - ref_avg, (new_avg-ref_avg)/ref_avg, 'MEAN' ))
47 
48 def main():
50 
51 from sys import exit
52 if __name__ == "__main__":
53  exit(main())
bool isnan(T value)
portable check to see if a value is NaN.
Definition: util.hh:47
bool isinf(T value)
Definition: util.hh:52
Fstring::size_type len(Fstring const &s)
Length.
Definition: Fstring.hh:2207
Real sum(ddGs &scores_to_sum)
bool open(utility::io::izstream &db_stream, std::string const &db_file, bool warn)
Open a database file on a provided stream.
Definition: open.cc:55
BooleanOptionKey const exit("options:exit")
Definition: OptionKeys.hh:51