Skip to content

gh-125985: Fix cmodule_function() scaling benchmark #128460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 3, 2025
Merged
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
14 changes: 11 additions & 3 deletions Tools/ftscalingbench/ftscalingbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,16 @@ def object_cfunction():

@register_benchmark
def cmodule_function():
for i in range(1000 * WORK_SCALE):
math.floor(i * i)
N = 1000 * WORK_SCALE
for i in range(N):
math.cos(i / N)

@register_benchmark
def object_lookup_special():
# round() uses `_PyObject_LookupSpecial()` internally.
N = 1000 * WORK_SCALE
for i in range(N):
round(i / N)

@register_benchmark
def mult_constant():
Expand Down Expand Up @@ -206,7 +214,7 @@ def benchmark(func):
color = "\x1b[33m" # yellow
reset_color = "\x1b[0m"

print(f"{color}{func.__name__:<18} {round(factor, 1):>4}x {direction}{reset_color}")
print(f"{color}{func.__name__:<25} {round(factor, 1):>4}x {direction}{reset_color}")

def determine_num_threads_and_affinity():
if sys.platform != "linux":
Expand Down
Loading