Open rstager opened 2 years ago
Initial tests on speedup for switching to a simulation time based architecture
Time different methods of scanning actors.
t1=time.process_time_ns()
for actor in self.actors:
pass
t2=time.process_time_ns()
for actor in random.choices(self.actors,k=100):
pass
t3=time.process_time_ns()
for actor in self.actors[:100]:
pass
t4=time.process_time_ns()
print(f"full list {t2-t1} partial list {t4-t3} choices {t3-t2}")
full list 190156 partial list 5566 choices 64706
Using random.choices is 3x faster than iterating through entire list (1% choices)
Time spent in just disease t1=time.process_time_ns() self.tickInteractions(days) self.tickRapidTesting(days) self.tickPcrTesting(days) self.tickVaccination(days) t2=time.process_time_ns() self.tickDisease(days) t3=time.process_time_ns() print(f"{t3-t1} {t3-t2} {(t3-t2)/(t3-t1):.3f}")
166132816 29167130 0.176 157937118 32239619 0.204
Lots of variability but approx 20% spent in iterating on just disease progression
Instead of keeping a timer for every infection and incrementing all of the individual clocks once per tick, we could timestamp the infection date/time and compare that against the simulation clock.
Do a performance analysis to see if this is worthwhile.