From 81622d4f8796ad0f7fef4347e8afc210c7a1884c Mon Sep 17 00:00:00 2001 From: David Hendriks <davidhendriks93@gmail.com> Date: Fri, 15 Jan 2021 23:45:08 +0000 Subject: [PATCH] added thingy to log runtimes --- binarycpython/utils/grid.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py index 6c02274d0..c6d8d3dc2 100644 --- a/binarycpython/utils/grid.py +++ b/binarycpython/utils/grid.py @@ -876,6 +876,9 @@ class Population: This function is called by _evolve_population_grid """ + # set start timer + start_process_time = datetime.datetime.now() + self.process_ID = ( ID # Store the ID as a object property again, lets see if that works. ) @@ -942,9 +945,18 @@ class Population: binary_cmdline_string = self._return_argline(full_system_dict) f.write(binary_cmdline_string) + start_runtime_binary_c = time.time() + # Evolve the system self._evolve_system_mp(full_system_dict) + end_runtime_binary_c = time.time() + + # Debug line: logging all the lines + with open(os.path.join(self.grid_options["tmp_dir"], "thread_{}_runtime_systems.txt".format(self.process_ID)), 'a+') as f: + binary_cmdline_string = self._return_argline(full_system_dict) + f.write("{} {}\n".format(end_runtime_binary_c-start_runtime_binary_c, binary_cmdline_string)) + # Keep track of systems: probability_of_systems_run += full_system_dict["probability"] number_of_systems_run += 1 @@ -1008,10 +1020,14 @@ class Population: "_count": number_of_systems_run, } + end_process_time = datetime.datetime.now() + verbose_print( - "Process {}: generator done at {}. Ran {} systems with a total probability of {}. This thread had {} failing systems with a total probability of {}".format( + "Process {} finished:\n\tgenerator started at {}, done at {} (total: {}s).\n\tRan {} systems with a total probability of {}.\n\tThis thread had {} failing systems with a total probability of {}".format( ID, - datetime.datetime.now().isoformat(), + start_process_time.isoformat(), + end_process_time.isoformat(), + (end_process_time-start_process_time).total_seconds(), number_of_systems_run, probability_of_systems_run, self.grid_options["_failed_count"], -- GitLab