Test memory_profiler
This commit is contained in:
parent
7742172968
commit
397ad2056e
1 changed files with 23 additions and 0 deletions
23
mem-profile.py
Normal file
23
mem-profile.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
from memory_profiler import profile
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
# From
|
||||||
|
# http://stackoverflow.com/questions/27464039/why-the-performance-difference-between-numpy-zeros-and-numpy-zeros-like
|
||||||
|
|
||||||
|
N = (1000, 1000)
|
||||||
|
M = (slice(None, 500, None), slice(500, None, None))
|
||||||
|
|
||||||
|
@profile
|
||||||
|
def test1(N, M):
|
||||||
|
print(N, M)
|
||||||
|
x = np.zeros(N)
|
||||||
|
y = np.empty(N)
|
||||||
|
z = np.zeros_like(x)
|
||||||
|
x[M] = 1
|
||||||
|
y[M] = 1
|
||||||
|
z[M] = 1
|
||||||
|
return x,y,z
|
||||||
|
|
||||||
|
test1(N, M)
|
Loading…
Add table
Add a link
Reference in a new issue