From 20c4c98359379561b883c8ad7427c578a89400c1 Mon Sep 17 00:00:00 2001 From: Avimanyu Bandyopadhyay Date: Thu, 3 May 2018 22:42:51 +0530 Subject: [PATCH 1/2] Setting a timer to view progress in real time To show time elapsed since simulations begin when reporting number of cells produced. Keeping 3 different time units (hours/minutes/seconds) for the convenience of user's own differently timed experiments. --- CellModeller/Biophysics/BacterialModels/CLBacterium.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CellModeller/Biophysics/BacterialModels/CLBacterium.py b/CellModeller/Biophysics/BacterialModels/CLBacterium.py index 8bc53b4e..b5e8788d 100644 --- a/CellModeller/Biophysics/BacterialModels/CLBacterium.py +++ b/CellModeller/Biophysics/BacterialModels/CLBacterium.py @@ -39,6 +39,11 @@ def __init__(self, simulator, self.frame_no = 0 self.simulator = simulator self.regulator = None + + self.time_begin = time.time() + self.seconds_elapsed = 0 + self.minutes_elapsed = 0 + self.hours_elapsed = 0 self.max_cells = max_cells self.max_contacts = max_contacts @@ -498,8 +503,11 @@ def progress(self): def progress_finalise(self): self.frame_no += 1 self.progress_initialised = False + self.seconds_elapsed = numpy.float32(time.time() - self.time_begin) + self.minutes_elapsed = (numpy.float32(self.seconds_elapsed) / 60.0) + self.hours_elapsed = (numpy.float32(self.minutes_elapsed) / 60.0) if self.frame_no % 10 == 0: - print '% 8i % 8i cells % 8i contacts' % (self.frame_no, self.n_cells, self.n_cts) + print '% 8i % 8i cells % 8i contacts %f hour(s) or %f minute(s) or %f second(s)' % (self.frame_no, self.n_cells, self.n_cts, self.hours_elapsed, self.minutes_elapsed, self.seconds_elapsed) # pull cells from the device and update simulator if self.simulator: self.get_cells() From 2f42948014037f0fdc867b5cca05f739cd9cba0b Mon Sep 17 00:00:00 2001 From: Avimanyu Bandyopadhyay Date: Thu, 3 May 2018 22:49:32 +0530 Subject: [PATCH 2/2] import time --- CellModeller/Biophysics/BacterialModels/CLBacterium.py | 1 + 1 file changed, 1 insertion(+) diff --git a/CellModeller/Biophysics/BacterialModels/CLBacterium.py b/CellModeller/Biophysics/BacterialModels/CLBacterium.py index b5e8788d..384e3fc7 100644 --- a/CellModeller/Biophysics/BacterialModels/CLBacterium.py +++ b/CellModeller/Biophysics/BacterialModels/CLBacterium.py @@ -7,6 +7,7 @@ from pyopencl.elementwise import ElementwiseKernel from pyopencl.reduction import ReductionKernel import random +import time ct_map = {}