pocketpy/tests/910_line_profiler.py
zhs628 fc991ab697
Increase coverage 2025 12 01 (#412)
* 通过引发py_call错误覆盖相关调用者的ok==false分支

* Revert "通过引发py_call错误覆盖相关调用者的ok==false分支"

This reverts commit 36dc0b5d81a02a83dfdeca2d4d6d265f5f793b4b.

* add test

* rename test files

* fix bugs

* fix bugs
2025-12-04 21:01:29 +08:00

30 lines
448 B
Python

try:
from line_profiler import LineProfiler
print('[INFO] line_profiler is used')
except ImportError:
exit(0)
def f2(x):
a = 0
for i in range(x):
if i % 5 == 0:
a += i
return a
def f1(x):
res = f2(x)
return res
lp = LineProfiler()
lp.add_function(f2)
# lp.runcall(f2, 1000000)
# lp.print_stats()
###############################
lp.add_function(f1)
lp.runcall(f1, 1000000)
lp.print_stats()