Closed
Description
Reproducing code example:
Write a demo.py
:
from __future__ import print_function
import time
import numpy as np
import six
if six.PY3:
timer_func = time.process_time
else:
timer_func = time.clock
n = 1000
start = timer_func()
precise = 2
for i in range(n):
np.round(np.array(range(i)), precise)
end = timer_func()
print(end-start)
Then run it like this:
# Py2
python -m cProfile -o demo-py2.prof demo.py
# Py3
python -m cProfile -o demo-py3.prof demo.py
And view the profiles with snakeviz pip install snakeviz
:
# Under Python2's virtual env:
snakeviz demo-py2.prof
# Under Python3's virtual env:
snakeviz demo-py2.prof
Get web page:
And the purple part it time cost on loading packages.
Error message:
Numpy/Python version information:
>>> import sys, numpy; print(numpy.__version__, sys.version)
1.16.4 2.7.16 (default, Apr 12 2019, 15:32:40)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.3)]
>>> import sys, numpy; print(numpy.__version__, sys.version)
1.16.4 3.7.4 (default, Jul 9 2019, 18:13:23)
[Clang 10.0.1 (clang-1001.0.46.4)]
Metadata
Metadata
Assignees
Labels
No labels