File tree Expand file tree Collapse file tree 5 files changed +61
-16
lines changed Expand file tree Collapse file tree 5 files changed +61
-16
lines changed File renamed without changes.
Original file line number Diff line number Diff line change 1+ import gc
2+
3+ from time import perf_counter as time
4+
5+ from util import cls , N
6+
7+
8+ def main ():
9+ objs = [None ] * N
10+ for i in range (N ):
11+ objs [i ] = cls ()
12+ return objs
13+
14+
15+ gc .collect ()
16+
17+ t_start = time ()
18+ main ()
19+ print (f"time per allocation: { (time () - t_start )/ N :.1e} s" )
Original file line number Diff line number Diff line change 1+ import gc
2+
3+ from time import perf_counter as time
4+
5+ from util import cls , N
6+
7+
8+ def main ():
9+ for _ in range (N ):
10+ obj = cls ()
11+ obj .onearg (None )
12+
13+
14+ gc .collect ()
15+
16+ t_start = time ()
17+ main ()
18+ print (f"time per allocation: { (time () - t_start )/ N :.1e} s" )
Original file line number Diff line number Diff line change 1+ import gc
2+
3+ from time import perf_counter as time
4+
5+ from util import cls , N
6+
7+ N *= 40
8+
9+ def main ():
10+ obj = cls ()
11+ for _ in range (N ):
12+ # note: here we are NOT calling it, we want to measure just
13+ # the lookup
14+ obj .noargs # pylint: disable=W0104
15+
16+
17+ gc .collect ()
18+
19+ t_start = time ()
20+ main ()
21+ print (f"time per allocation: { (time () - t_start )/ N :.1e} s" )
Original file line number Diff line number Diff line change 1-
2- import gc
31import sys
42
5- from time import perf_counter as time
6-
73if "purepy" in sys .argv :
84 import purepy_simple as simple
95elif "cpy" in sys .argv :
1713print (simple )
1814
1915cls = simple .HTFoo
16+
2017N = 10000000
2118if sys .implementation .name == "cpython" :
2219 N *= 10
23-
24- def main ():
25- objs = [None ] * N
26- for i in range (N ):
27- objs [i ] = cls ()
28- return objs
29-
30- gc .collect ()
31-
32- t_start = time ()
33- main ()
34- print (f"time per allocation: { (time () - t_start )/ N :.1e} s" )
20+ elif sys .implementation .name == "pypy" and "cpy" in sys .argv :
21+ N *= 4
You can’t perform that action at this time.
0 commit comments