From 823fdbc3074a64de3b42132af47e63207f64d9d1 Mon Sep 17 00:00:00 2001 From: Richard Feistenauer Date: Sat, 9 Feb 2019 18:16:19 +0100 Subject: [PATCH] some more tests and improvements --- performance.txt | 8 ++- scripts/main_ui.py | 5 +- scripts/performance_test | Bin 0 -> 3861 bytes src/cellular_automaton/__init__.py | 7 +++ src/cellular_automaton/ca_cell.py | 22 +++---- src/cellular_automaton/ca_display.py | 8 ++- src/cellular_automaton/ca_factory.py | 60 ++++++------------- src/cellular_automaton/cellular_automaton.py | 3 +- test/test_factory.py | 50 ++++++++++++++++ test/test_neighborhood.py | 5 +- 10 files changed, 104 insertions(+), 64 deletions(-) create mode 100644 scripts/performance_test create mode 100644 test/test_factory.py diff --git a/performance.txt b/performance.txt index 3bf28aa..c9fec8b 100644 --- a/performance.txt +++ b/performance.txt @@ -8,4 +8,10 @@ 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 \ No newline at end of file +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 \ No newline at end of file diff --git a/scripts/main_ui.py b/scripts/main_ui.py index 80c85a3..a01e5cc 100644 --- a/scripts/main_ui.py +++ b/scripts/main_ui.py @@ -4,7 +4,7 @@ from cellular_automaton.ca_cell_state import CellState from cellular_automaton.ca_rule import Rule from cellular_automaton.cellular_automaton import CellularAutomaton, CellularAutomatonProcessor -from cellular_automaton.ca_factory import Factory +from cellular_automaton.ca_factory import CAFactory class TestRule(Rule): @@ -35,8 +35,7 @@ class MyState(CellState): def make_cellular_automaton(dimension, neighborhood, rule, state_class): - ca_factory = Factory() - cells = ca_factory.make_cellular_automaton(dimension=dimension, neighborhood=neighborhood, state_class=state_class) + cells = CAFactory.make_cellular_automaton(dimension=dimension, neighborhood=neighborhood, state_class=state_class) return CellularAutomaton(cells, dimension, rule) diff --git a/scripts/performance_test b/scripts/performance_test new file mode 100644 index 0000000000000000000000000000000000000000..112495e103f620ce1aa9a7d2fc78540540b2e869 GIT binary patch literal 3861 zcmbtXTWl0n7%rCHZK=quV(D@zwX|I;HP(+{oF+Sf!nOhnB{CrKiOBy~0NKq9eDwbaOFBdU_fR%&3X#?8pqK5M6; zXMVM`Hnpsd5Un#}?W9PJX*v!k`ch}|^76)t6-CoEOHt|zQl;>K&V~gK#u`g^3@(!S zrvHO{It$)tQ?Sx}*wxRrp)=r{>m7V*5};!xih^_tQO4r=s-$Y;)jiwJNO7$7oU6AK*$wZUPU66I^2iC5mP$MvsnSf*Vil8J+)9PKpY06Js^UMo`yRgD})m^ktLk(@dMLeJowBd z3A>wqNRWAOA=&^7^#YcbeL}3eK>h_MVaeeHmiJ^nIk&#;;Z&uJ3l3KuL*sDTF2f5P z?@ieN9_*({j+0zxM3ZqyUnnY0b&1<2WEU8v$DkypV5B3eLbygu8jVB|AxWZAMNL{p z93JaA9NZF>QhF6jiz5@t5UVrvHdwF|aT5~m7~g*WLh}*k(^zqvX;F|M z*% zrQXm8;JN)CX1`Pc0!20Z^r%1+fAaos9@8s%g2z@Ui$$&x1Y^8uYKNR{wybp*8k4xVXgm60vK+SX`n0pnt3Vuvh_{#`AKGT zh2LfX!)<2I&8u_%!A(c!Jqn3Xa;5R@fgw42kL>#Ca=-lmp4n$!EzN)kkD=X31dltPf+wbw<5EUoMzC*ZBv)f{UvbP#0%Dq}b`nMf z3KU{O#qSD3RqN6SqJn^IB>@-gAM9@WMeB`O_ngk1vF?moVPZsgc`c{z06Vk+7W~u4 zefO?7KO*xDtJrq&o5L`bun6(yP7K)HxbRyTe6Anv%m}C5Vd1otnH5qjq-i58c=*Gn z%5CRBfxDT>waoZ)eb+oQSKvmtYd16Ua=+F9UKA4MXUqr58Uk#sV z{#C;6CWl7%6~~B_OJ=4dNN04cEI75{T20y9tIB>>x>jS>a|4o_(