Skip to content

Commit 4c078f8

Browse files
committed
microbench/profile: rename and few other scripts
1 parent dca6fae commit 4c078f8

File tree

5 files changed

+61
-16
lines changed

5 files changed

+61
-16
lines changed
File renamed without changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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")
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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")
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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")
Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
2-
import gc
31
import sys
42

5-
from time import perf_counter as time
6-
73
if "purepy" in sys.argv:
84
import purepy_simple as simple
95
elif "cpy" in sys.argv:
@@ -17,18 +13,9 @@
1713
print(simple)
1814

1915
cls = simple.HTFoo
16+
2017
N = 10000000
2118
if 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

0 commit comments

Comments
 (0)