Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d9124f3

Browse files
committed
Simplify profiling code
1 parent 0cd4097 commit d9124f3

1 file changed

Lines changed: 6 additions & 40 deletions

File tree

Lib/test/test_profiling/test_sampling_profiler/test_integration.py

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -385,49 +385,15 @@ def cpu_intensive_work():
385385
result = result % 1000000
386386
return result
387387
388-
def medium_computation():
389-
"""Medium complexity function."""
390-
result = 0
391-
for i in range(100):
392-
result += i * i
393-
return result
394-
395-
def fast_loop():
396-
"""Fast simple loop."""
397-
total = 0
398-
for i in range(50):
399-
total += i
400-
return total
401-
402-
def nested_calls():
403-
"""Test nested function calls."""
404-
def level1():
405-
def level2():
406-
return medium_computation()
407-
return level2()
408-
return level1()
409-
410388
def main_loop():
411-
"""Main test loop with different execution paths."""
412-
max_iterations = 1000
389+
"""Main test loop."""
390+
max_iterations = 200
413391
414-
iteration = 0
415-
416-
while iteration < max_iterations:
417-
iteration += 1
418-
419-
# Different execution paths - focus on CPU intensive work
420-
if iteration % 3 == 0:
421-
# Very CPU intensive
422-
result = cpu_intensive_work()
423-
elif iteration % 5 == 0:
424-
# Expensive recursive operation
425-
result = slow_fibonacci(12)
392+
for iteration in range(max_iterations):
393+
if iteration % 2 == 0:
394+
result = slow_fibonacci(15)
426395
else:
427-
# Medium operation
428-
result = nested_calls()
429-
430-
# No sleep - keep CPU busy
396+
result = cpu_intensive_work()
431397
432398
if __name__ == "__main__":
433399
main_loop()

0 commit comments

Comments
 (0)