Skip to content

Instantly share code, notes, and snippets.

@olegsinavski
Created November 26, 2019 18:09
Show Gist options
  • Save olegsinavski/502af97928c26b28f6ec45ed7c305904 to your computer and use it in GitHub Desktop.
Save olegsinavski/502af97928c26b28f6ec45ed7c305904 to your computer and use it in GitHub Desktop.
Profile numpy version onliner array 180
import numpy as np
from shining_software.utilities.profiling_utils import profiler
print(np.__version__)
with profiler(enable=True):
size = 180
for i in range(1000000):
np.amax(np.empty((size, size)))
'''
print(np.__version__)
with profiler(enable=True):
size = 180
for i in range(1000000):
np.amax(np.empty((size, size)))
numpy 11
6000004 function calls in 11.622 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
1000000 9.338 0.000 9.338 0.000 {method 'reduce' of 'numpy.ufunc' objects}
1000000 0.891 0.000 10.663 0.000 fromnumeric.py:69(_wrapreduction)
1000000 0.630 0.000 11.293 0.000 fromnumeric.py:2397(amax)
1000000 0.313 0.000 0.313 0.000 fromnumeric.py:70(<dictcomp>)
1000000 0.310 0.000 0.310 0.000 {numpy.empty}
1000000 0.121 0.000 0.121 0.000 {method 'items' of 'dict' objects}
1 0.019 0.019 0.019 0.019 {range}
numpy 16
4000004 function calls in 9.674 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
1000000 8.639 0.000 8.639 0.000 {method 'reduce' of 'numpy.ufunc' objects}
1000000 0.466 0.000 9.341 0.000 fromnumeric.py:2180(amax)
1000000 0.309 0.000 0.309 0.000 {numpy.core.multiarray.empty}
1000000 0.235 0.000 8.875 0.000 _methods.py:25(_amax)
1 0.025 0.025 0.025 0.025 {range}
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment