Source code for pydfnworks.general.general_functions

import os
import sys


[docs]def dump_time(self, function_name, time): '''Write run time for a funcion to the jobname_run_time.txt file Parameters ---------- self : object DFN Class function_name : string Name of function that was timed time : float Run time of function in seconds Returns ---------- None Notes --------- While this function is working, the current formulation is not robust through the entire workflow ''' run_time_file = self.jobname + os.sep + self.local_jobname + "_run_time.txt" # Check if time file exists, if not create it if not os.path.isfile(run_time_file): f = open(run_time_file, "w") f.write("Runs times for " + self.local_jobname + "\n") else: f = open(run_time_file, "a") # Write Time if time < 60.0: f.write(function_name + " : %0.2f seconds\n" % time) else: f.write(function_name + " : %0.2f minutes\n" % (time / 60.0)) f.close()