From 1782d32e8caf506cb1b37e6a3cc8cc79275c6c88 Mon Sep 17 00:00:00 2001 From: Richard Feistenauer Date: Sun, 17 Feb 2019 11:17:20 +0100 Subject: [PATCH] removed performance test --- cellular_automaton/display.py | 29 ++-------------------------- performance.txt | 36 ----------------------------------- 2 files changed, 2 insertions(+), 63 deletions(-) delete mode 100644 performance.txt diff --git a/cellular_automaton/display.py b/cellular_automaton/display.py index 505c24e..d3745f8 100644 --- a/cellular_automaton/display.py +++ b/cellular_automaton/display.py @@ -2,11 +2,6 @@ import pygame import time import operator -import cProfile -import pstats -from pympler import asizeof - - from . import CellularAutomatonState, CellularAutomatonProcessor @@ -61,6 +56,7 @@ class PyGameFor2D: self._screen.fill([0, 0, 0], ((0, 0), (self._window_size[0], 30))) self._write_text((10, 5), "CA: " + "{0:.4f}".format(time_ca_end - time_ca_start) + "s") self._write_text((310, 5), "Display: " + "{0:.4f}".format(time_ds_end - time_ca_end) + "s") + self._write_text((660, 5), "Step: " + str(self._cellular_automaton.current_evolution_step)) def _write_text(self, pos, text, color=(0, 255, 0)): label = self._font.render(text, 1, color) @@ -69,33 +65,12 @@ class PyGameFor2D: def main_loop(self, cellular_automaton_processor: CellularAutomatonProcessor, evolution_steps_per_draw): running = True - cellular_automaton_processor.evolve() - first = True while running: pygame.event.get() time_ca_start = time.time() - if first: - self._evolve_with_performance(cellular_automaton_processor) - first = False - else: - cellular_automaton_processor.evolve_x_times(evolution_steps_per_draw) + cellular_automaton_processor.evolve_x_times(evolution_steps_per_draw) time_ca_end = time.time() self.ca_display.redraw_cellular_automaton() time_ds_end = time.time() self._print_process_duration(time_ca_end, time_ca_start, time_ds_end) - - def _evolve_with_performance(self, cap): - size = asizeof.asizeof(self._cellular_automaton) - time_ca_start = time.time() - cProfile.runctx("cap.evolve_x_times(10)", None, locals(), "performance_test") - time_ca_end = time.time() - print("PERFORMANCE") - p = pstats.Stats('performance_test') - p.strip_dirs() - # sort by cumulative time in a function - p.sort_stats('cumulative').print_stats(10) - # sort by time spent in a function - p.sort_stats('time').print_stats(10) - print("TOTAL TIME: " + "{0:.4f}".format(time_ca_end - time_ca_start) + "s") - print("SIZE: " + "{0:.4f}".format(size / (1024 * 1024)) + "MB") diff --git a/performance.txt b/performance.txt deleted file mode 100644 index c833315..0000000 --- a/performance.txt +++ /dev/null @@ -1,36 +0,0 @@ -# ~Goal -def time_test(s, l): - first = time.time() - for i in range(100000): - s = l[i % 2] - last = time.time() - print((last-first)/100000) - -time_test(1, [2, 1]) -1.401543617248535e-07 - -heist auf einem processor ohne synchronized müsste ich ca 10 mal schneller sein? oder 3.3 mal weil 3 prozesse weniger? - -# With 100x100 10 times - -Try One -TOTAL TIME: 0.1217s -SIZE: 21.7525MB - -TOTAL TIME: 0.1171s # Only set on change -SIZE: 21.7525MB # process size 51,4 / main(75,9) - -TOTAL TIME: 0.1161s -SIZE: 20.3338MB # removed grid - -TOTAL TIME: 0.1792s # probably wrong calculated (asizeof was in there) -SIZE: 20.2575MB # Factory instead of grid - -TOTAL TIME: 0.1152s # dict instead of list for cells -SIZE: 20.2575MB # process size 53 / 75,8 - -TOTAL TIME: 0.1135s # evolve is static -SIZE: 20.2575MB # process size 50.8 / 76 (no more cell objects in processes) - -TOTAL TIME: 0.1126s # fixed changed state -SIZE: 20.8678MB \ No newline at end of file