I tried fastero after listening to the April 28 2022 episode of Python Bytes.
I wanted to time two functions one that used global and one that didn't.
python -m fastero "file: not_using_global.py" "file: using_global.py"
ββββββββββββββββββββββββββββββββββββββββββββββββββ Benchmark startedβ¦ ββββββββββββββββββββββββββββββββββββββββββββββββββ
Benchmark 1: R = 8.314
def not_calling_global():
R * 10
not_calling_global()
Time (mean Β± Ο): 196.1 ns Β± 5.2 ns
Range (min β¦ max): 190.9 ns β¦ 204.9 ns [runs: 14,000,000]
Benchmark 2: R = 8.314
def calling_global():
global R
R * 10
calling_global()
Traceback (most recent call last):
File "C:\Users\XXX\Anaconda3\envs\eos\lib\site-packages\fastero\core.py", line 475, in app
num_in_one_batch, time_taken = _autorange(timer, autorange_callback)
File "C:\Users\rlarson\Anaconda3\envs\eos\lib\site-packages\fastero\core.py", line 461, in _autorange
time_taken = timer.timeit(number)
File "C:\Users\XXX\Anaconda3\envs\eos\lib\timeit.py", line 178, in timeit
timing = self.inner(it, self.timer)
File "<timeit-src>", line 14, in inner
calling_global()
File "<timeit-src>", line 11, in calling_global
R * 10
NameError: name 'R' is not defined
if I run the file "using_global.py" with python I do not get the error related to this file.