Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions microbench/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ make print_graalpy

make print_pypy_vs_cpy
make print_graalpy_vs_cpy

# example comparison on only one test
.venv_cpy/bin/python -m pytest test_microbench.py::TestType::test_allocate_obj[cpy]
.venv_pypy/bin/python -m pytest test_microbench.py::TestType::test_allocate_obj[hpy]
```

[Pixi]: https://pixi.sh
Expand Down
1 change: 1 addition & 0 deletions microbench/pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ version = "0.1.0"
gcc = ">=15.1.0,<15.2"
valgrind = ">=3.25.0,<4"
libffi = ">=3.4.6,<4"
libxcrypt = ">=4.4.36,<5"
13 changes: 12 additions & 1 deletion microbench/test_microbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class TestType:
The type is named `simple.Foo` in both cases.
"""

def test_allocate_obj(self, simple, timer, N):
def test_allocate_and_collect(self, simple, timer, N):
import gc
Foo = simple.Foo
objs = [None] * N
Expand All @@ -109,6 +109,17 @@ def test_allocate_obj(self, simple, timer, N):
del objs
gc.collect()

def test_allocate_obj(self, simple, timer, N):
import gc
Foo = simple.Foo
objs = [None] * N
gc.collect()
with timer:
for i in range(N):
objs[i] = Foo()
del objs
gc.collect()

def test_method_lookup(self, simple, timer, N):
obj = simple.Foo()
with timer:
Expand Down