From b2fb5ec595c3546674bb88e5439006ffc79d7371 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Thu, 17 Apr 2025 21:23:28 +0200 Subject: [PATCH 1/2] Add free-threading scaling bm --- Tools/ftscalingbench/ftscalingbench.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Tools/ftscalingbench/ftscalingbench.py b/Tools/ftscalingbench/ftscalingbench.py index 364c465bc91b0b..9d0d6c8e06a4d1 100644 --- a/Tools/ftscalingbench/ftscalingbench.py +++ b/Tools/ftscalingbench/ftscalingbench.py @@ -27,6 +27,7 @@ import sys import threading import time +import copy # The iterations in individual benchmarks are scaled by this factor. WORK_SCALE = 100 @@ -37,11 +38,25 @@ in_queues = [] out_queues = [] - def register_benchmark(func): ALL_BENCHMARKS[func.__name__] = func return func + +@register_benchmark +def shallow_copy(): + x = [1, 2, 3] + shallow_copy = copy.copy + for i in range(200 * WORK_SCALE): + shallow_copy(x) + +@register_benchmark +def deepcopy(): + x = {'list': [1, 2], 'tuple': (1, None)} + deepcopy = copy.deepcopy + for i in range(40 * WORK_SCALE): + deepcopy(x) + @register_benchmark def object_cfunction(): accu = 0 From 430cb5c39cc9ae93b9e96291fd1835e93e3e6cf4 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Mon, 21 Apr 2025 22:53:26 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Sam Gross --- Tools/ftscalingbench/ftscalingbench.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Tools/ftscalingbench/ftscalingbench.py b/Tools/ftscalingbench/ftscalingbench.py index 9d0d6c8e06a4d1..ec265c9d2fb109 100644 --- a/Tools/ftscalingbench/ftscalingbench.py +++ b/Tools/ftscalingbench/ftscalingbench.py @@ -46,16 +46,14 @@ def register_benchmark(func): @register_benchmark def shallow_copy(): x = [1, 2, 3] - shallow_copy = copy.copy for i in range(200 * WORK_SCALE): - shallow_copy(x) + copy.copy(x) @register_benchmark def deepcopy(): x = {'list': [1, 2], 'tuple': (1, None)} - deepcopy = copy.deepcopy for i in range(40 * WORK_SCALE): - deepcopy(x) + copy.deepcopy(x) @register_benchmark def object_cfunction():