Skip to content

Commit

Permalink
fix end-of-simulation stats when simulating 0 periods (closes #158)
Browse files Browse the repository at this point in the history
  • Loading branch information
gdementen committed May 19, 2015
1 parent a2dc3fc commit bef1c33
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/simulation.py
Expand Up @@ -498,23 +498,21 @@ def simulate_period(period_idx, period, processes, entities,
self.processes, self.entities)

total_objects = sum(period_objects[period] for period in periods)
total_time = time.time() - main_start_time
try:
ind_per_sec = str(int(total_objects / total_time))
except ZeroDivisionError:
ind_per_sec = 'inf'
avg_objects = str(total_objects // self.periods) \
if self.periods else 'N/A'
main_elapsed_time = time.time() - main_start_time
ind_per_sec = str(int(total_objects / main_elapsed_time)) \
if main_elapsed_time else 'inf'

print("""
==========================================
simulation done
==========================================
* %s elapsed
* %d individuals on average
* %s individuals on average
* %s individuals/s/period on average
==========================================
""" % (time2str(time.time() - start_time),
total_objects / self.periods,
ind_per_sec))
""" % (time2str(time.time() - start_time), avg_objects, ind_per_sec))

show_top_processes(process_time, 10)
# if config.debug:
Expand Down

0 comments on commit bef1c33

Please sign in to comment.