Skip to content

Commit

Permalink
Add function call benchmark
Browse files Browse the repository at this point in the history
This adds a benchmark that compares
calling math.sin with doing the same
using the PyObjC machinery.
  • Loading branch information
ronaldoussoren committed May 20, 2021
1 parent d8172e1 commit 4162b20
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pyobjc-core/Tools/pyobjcbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,17 @@ def print_bench(title, time):
stmt="m()",
),
)
print()
print_bench(
"python function call",
timeit.timeit(setup="import math; f=math.sin", stmt="f(5.0)"),
)
setup = """
import objc
objc.loadBundleFunctions(None, globals(), [("sin", b"dd")])
f = sin
"""
print_bench(
"objc function call",
timeit.timeit(setup=setup, stmt="f(5.0)"),
)

0 comments on commit 4162b20

Please sign in to comment.