6 '''Write run time for a funcion to the jobname_run_time.txt file
12 function_name : string
13 Name of function that was timed
15 Run time of function in seconds
23 While this function is working, the current formulation is not robust through the entire workflow
25 run_time_file = self.jobname + os.sep + self.local_jobname +
"_run_time.txt"
27 if not os.path.isfile(run_time_file):
28 f = open(run_time_file,
"w")
29 f.write(
"Runs times for " + self.local_jobname +
"\n")
31 f = open(run_time_file,
"a")
34 f.write(function_name +
" : %0.2f seconds\n" % time)
36 f.write(function_name +
" : %0.2f minutes\n" % (time / 60.0))
41 '''Read in run times from file and and print to screen with percentages
54 This will dump out all values in the run file, not just those from the most recent run
56 run_time_file = self.jobname + os.sep + self.local_jobname +
"_run_time.txt"
57 f = open(run_time_file).readlines()
58 unit = f[-1].split()[-1]
59 total = float(f[-1].split()[-2])
63 print(
'Runs times for ', f[0])
66 for i
in range(1, len(f)):
67 unit = f[i].split()[-1]
68 time = float(f[i].split()[-2])
72 percent.append(100.0 * (time / total))
73 name.append(f[i].split(
':')[1])
74 print(f[i],
'\t--> Percent if total %0.2f \n' % percent[i - 1])
def dump_time(self, function_name, time)