Debian Codegraph @

profile/profile.py

raw symbols SCIP
1 import numpy as np
2 from skfmm import distance
3 import time
4 import pylab as pl
5
6 def p(m): pl.matshow(m); pl.colorbar(); pl.show()
7 def c(m): pl.contour(m); pl.colorbar(); pl.show()
8 def cf(m): pl.contourf(m); pl.colorbar(); pl.show()
9
10
11 def test0():
12 "circular level"
13 N = 1500
14 X, Y = np.meshgrid(np.linspace(-1,1,N),np.linspace(-1,1,N))
15 r = 0.5
16 dx = [2./(N-1),2./(N-1)]
17 phi = (X)**2 + (Y)**2-r**2
18 phi = np.ones_like(phi)
19 phi[0][0]=-1
20 t0=time.time()
21 d = distance(phi,dx)
22 t1=time.time()
23 print("benchmark time", t1-t0)
24 return d
25
26 import cProfile
27 cProfile.run('test0()', 'data')
28
29 import pstats
30 p=pstats.Stats('data')
31 p.strip_dirs().sort_stats('cumulative').print_stats(10)