All Samples(4275) | Call(3945) | Derive(0) | Import(330)
clock() -> floating point number Return the CPU time or real time since the start of the process or since the first call to clock(). This has as much precision as the system records.
src/p/y/pypy3-HEAD/pypy/interpreter/pyparser/test/unittest_samples.py pypy3(Download)
raise AssertionError('Found difference at %s : %s != %s' %
(curpos, name(elt1), name(elt2) ), curpos)
from time import time, clock
def test_samples( samples ):
time_reports = {}
for sample in samples:
print "testing", sample
tstart1, cstart1 = time(), clock()
pypy_tuples = pypy_parse(sample)
tstart2, cstart2 = time(), clock()
python_tuples = python_parse(sample)
time_reports[sample] = (time() - tstart2, tstart2-tstart1, clock() - cstart2, cstart2-cstart1 )
src/p/y/pypy-HEAD/pypy/interpreter/pyparser/test/unittest_samples.py pypy(Download)
raise AssertionError('Found difference at %s : %s != %s' %
(curpos, name(elt1), name(elt2) ), curpos)
from time import time, clock
def test_samples( samples ):
time_reports = {}
for sample in samples:
print "testing", sample
tstart1, cstart1 = time(), clock()
pypy_tuples = pypy_parse(sample)
tstart2, cstart2 = time(), clock()
python_tuples = python_parse(sample)
time_reports[sample] = (time() - tstart2, tstart2-tstart1, clock() - cstart2, cstart2-cstart1 )
src/m/a/matplotlib-HEAD/toolkits/basemap-0.9.6.1/examples/ireland.py matplotlib(Download)
draw()
time.sleep(5)
t1 = time.clock()
# create new figure
#fig=figure()
clf()
print 'plotting with intermediate res boundaries ...'
# create Basemap instance. Use 'intermediate' resolution coastlines.
m = Basemap(llcrnrlon=-11.,llcrnrlat=50.5,urcrnrlon=-5.,urcrnrlat=56.,
resolution='i',projection='tmerc',lon_0=-8.,lat_0=0.)
print time.clock()-t1,'seconds to create class instance with intermediate res coastlines'
#fig=figure()
clf()
# read cPickle back in and plot it again (should be much faster).
t1 = time.clock()
m2 = cPickle.load(open('map.pickle','rb'))
print time.clock()-t1,' to read the intermediate res coastline class instance back in from a cPickle'
# draw coastlines and fill continents.
sys.exit(0)
import time
t1 = time.clock()
# create new figure
#fig=figure()
clf()
print 'plotting with high res boundaries ...'
# create Basemap instance. Use 'high' resolution coastlines.
m = Basemap(llcrnrlon=-11.,llcrnrlat=50.5,urcrnrlon=-5.,urcrnrlat=56.,
resolution='h',projection='tmerc',lon_0=-8.,lat_0=0.)
print time.clock()-t1,'seconds to create class instance with high res coastlines'
#fig=figure()
clf()
# read cPickle back in and plot it again (should be much faster).
t1 = time.clock()
m2 = cPickle.load(open('map.pickle','rb'))
print time.clock()-t1,' to read the high res coastline class instance back in from a cPickle'
# draw coastlines and fill continents.
src/l/a/Langtangen-HEAD/src/py/examples/generator_expr.py Langtangen(Download)
print 'for k in xrange(N):'
term_prev = 0
t0 = time.clock()
for k in xrange(1,N):
term = k**(-0.3)
if smalldiff(term, term_prev):
t1 = time.clock()
yield k, k**(-0.3)
term_prev = 0
t0 = time.clock()
for k, term in g1(N):
if smalldiff(term, term_prev):
t1 = time.clock()
print 'time:', t1-t0, 'final k:', k
break
term_prev = term
print 'Generation of generator expression:',
t0 = time.clock()
g3 = ((k, k**(-0.3)) for k in xrange(1,N))
t1 = time.clock()
print t1-t0
term_prev = 0
t0 = time.clock()
for k, term in g3:
if smalldiff(term, term_prev):
t1 = time.clock()
# Alternative:
g3 = ((k, k**(-0.3)) for k in xrange(1,N))
term_prev = 0
t0 = time.clock()
k, term = g3.next()
while not smalldiff(term, term_prev):
term_prev = term
try:
k, term = g3.next()
except StopIteration:
print 'No convergence, use a larger N!...'
sys.exit(1)
t1 = time.clock()
print 'Generation of list:', t0 = time.clock() g2 = [(k, k**(-0.3)) for k in xrange(1,N)] t1 = time.clock() print t1-t0 term_prev = 0 t0 = time.clock()
t0 = time.clock()
for k, term in g2:
if smalldiff(term, term_prev):
t1 = time.clock()
print 'time:', t1-t0, 'final k:', k
break
term_prev = term
# Alternative:
term_prev = 0
t0 = time.clock()
while not smalldiff(term, term_prev):
term_prev = term
k, term = g2.pop(0)
t1 = time.clock()
print 'time:', t1-t0, 'final k:', k
src/l/a/Langtangen-HEAD/src/py/examples/pde/wave2D_func1_0.py Langtangen(Download)
time.sleep(1)
time.sleep(0.2) # pause between frames
t0 = time.clock()
implementation = {'ic': version, 'inner': version, 'bc': version}
nx = 40; ny = 40; tstop = 700
dt = solver(I2, f, c, bc, Lx, Ly, nx, ny, 0, tstop,
user_action=action, implementation=implementation)
t1 = time.clock()
color=0, fontname='Times-Roman')
time.sleep(0.8) # pause to finish plot
import time
t0 = time.clock()
viz = Visualizer(plot)
implementation = {'ic': version, 'inner': version, 'bc': version}
nx = 40; ny = 40; tstop = 700
dt = solver(I2, f, c, bc, Lx, Ly, nx, ny, 0, tstop,
user_action=viz, implementation=implementation)
t1 = time.clock()
#error.append((t, innerproduct(e.flat,e.flat)))
error.append(innerproduct(e.flat,e.flat))
t0 = time.clock()
implementation = {'ic': version, 'inner': version, 'bc': version}
nx = 10; ny = 4; tstop = 20
dt = solver(I1, f, c, bc, Lx, Ly, nx, ny, 0, tstop,
user_action=action, implementation=implementation)
t1 = time.clock()
implementation['ic'] = ic
implementation['inner'] = inner
implementation['bc'] = bc
t0 = time.clock()
dt = solver(I2, f, c, BC, Lx, Ly, nx, ny, 0, tstop,
user_action=None,
implementation=implementation,
verbose=False)
t1 = time.clock()
src/q/u/querychinesesto-HEAD/prog/gbk-encode-example.py querychinesesto(Download)
print '×Ö·û´®ÀàÐÍ', type(datetime.datetime.now().strftime('%Y-%m-%d'))
print 'structÀàÐÍ', type(time.strptime('2008-02-06', '%Y-%m-%d'))
print 'utc: ', time.gmtime(), 'local: ', time.localtime()
print time.clock()
print time.time(), time.mktime(time.localtime()), time.time() == time.mktime(time.localtime())
from datetime import datetime
src/d/a/dana-0.3.0/examples/benchmark.py dana(Download)
# Numpy regular array
Z = np.ones((n,n), dtype=np.double)
t0 = time.clock()
for i in range(epochs):
Z += (Z+1)*dt
print 'numpy: ', time.clock()-t0
print
# Numpy regular array + dynamic evaluation
Z[...] = 0
t0 = time.clock()
t0 = time.clock()
for i in range(epochs):
Z += eval("(Z+1)*dt")
print 'numpy + dynamic eval: ', time.clock()-t0
# Numpy regular array + static evaluation
expr = compile("(Z+1)*dt", "<string>", "eval")
Z[...] = 0
t0 = time.clock()
for i in range(epochs):
Z += eval(expr)
print 'numpy + static eval: ', time.clock()-t0
# Numpy regular array + dynamic execution
Z[...] = 0
t0 = time.clock()
for i in range(epochs):
exec('Z += (Z+1)*dt')
print 'numpy + dynamic exec: ', time.clock()-t0
# Numpy regular array + static execution
Z[...] = 0
expr = compile("Z += (Z+1)*dt", "<string>", "exec")
t0 = time.clock()
t0 = time.clock()
for i in range(epochs):
exec(expr)
print 'numpy + static exec: ', time.clock()-t0
print
# Numpy aligned interleaved array
Z = np.zeros((n,n),dtype=[('x',np.double), ('y',np.int)])['x']
t0 = time.clock()
for i in range(epochs):
Z += (Z+1)*dt
print 'aligned interleaved array: ', time.clock()-t0
# Numpy unaligned interleaved array
Z = np.zeros((n,n),dtype=[('x',np.double), ('y',np.bool)])['x']
t0 = time.clock()
for i in range(epochs):
Z += (Z+1)*dt
print 'unaligned interleaved array: ', time.clock()-t0
print
# Numpy subclass array
z = np.zeros((n,n), dtype=np.double)
Z = z.view(np.ndarray)
t0 = time.clock()
t0 = time.clock()
for i in range(epochs):
Z += (Z+1)*dt
print 'subclass array: ', time.clock()-t0
# Numpy aligned interleaved subclass array
z = np.zeros((n,n),dtype=[('x',np.double), ('y',np.int)])['x']
Z = z.view(array)
t0 = time.clock()
for i in range(epochs):
Z += (Z+1)*dt
print 'aligned interleaved subclass array: ', time.clock()-t0
# Numpy unaligned interleaved subclass array
z = np.zeros((n,n),dtype=[('x',np.double), ('y',np.bool)])['x']
Z = z.view(array)
t0 = time.clock()
for i in range(epochs):
Z += (Z+1)*dt
print 'unaligned interleaved subclass array:', time.clock()-t0
print
eq = Equation('Z = (Z+1)*dt : double')
Z = np.zeros((n,n))
t0 = time.clock()
t0 = time.clock()
for i in range(epochs):
Z += eq.evaluate(Z)
print 'dana equation: ', time.clock()-t0
eq = DifferentialEquation('dZ/dt = (Z+1) : double')
Z = np.zeros((n,n))
t0 = time.clock()
for i in range(epochs):
eq.evaluate(Z,dt)
print 'dana differential equation: ', time.clock()-t0
group = Group((n,n), 'dV/dt = (V+1) : double') group.V = 0 t0 = time.clock() group.run(t,dt) print 'dana group: ', time.clock()-t0
src/m/a/matplotlib-HEAD/matplotlib/examples/pylab_examples/simple_plot_fps.py matplotlib(Download)
frames = 100.0
t = time.time()
c = time.clock()
for i in xrange(int(frames)):
part = i / frames
axis([0.0, 1.0 - part, -1.0 + part, 1.0 - part])
wallclock = time.time() - t
user = time.clock() - c
src/c/s/csc-pysparse-HEAD/examples/poisson_test.py csc-pysparse(Download)
tol = 1e-8 n = 100 t1 = time.clock() L = poisson2d_sym_blk(n) print 'Time for constructing the matrix using poisson2d_sym_blk: %8.2f sec' % (time.clock() - t1, ) t1 = time.clock() L = poisson2d_sym(n) print 'Time for constructing the matrix using poisson2d_sym : %8.2f sec' % (time.clock() - t1, ) t1 = time.clock() L = poisson2d(n) print 'Time for constructing the matrix using poisson2d : %8.2f sec' % (time.clock() - t1, )
# --------------------------------------------------------------------------------------- t1 = time.clock() x = numpy.zeros(n*n, 'd') info, iter, relres = itsolvers.pcg(S, b, x, tol, 2000) print 'info=%d, iter=%d, relres=%e' % (info, iter, relres) print 'Time for solving the system using SSS matrix: %8.2f sec' % (time.clock() - t1, )
# --------------------------------------------------------------------------------------- t1 = time.clock() x = numpy.zeros(n*n, 'd') info, iter, relres = itsolvers.pcg(A, b, x, tol, 2000) print 'info=%d, iter=%d, relres=%e' % (info, iter, relres) print 'Time for solving the system using CSR matrix: %8.2f sec' % (time.clock() - t1, )
# --------------------------------------------------------------------------------------- t1 = time.clock() x = numpy.zeros(n*n, 'd') info, iter, relres = itsolvers.pcg(L, b, x, tol, 2000) print 'info=%d, iter=%d, relres=%e' % (info, iter, relres) print 'Time for solving the system using LL matrix: %8.2f sec' % (time.clock() - t1, )
# --------------------------------------------------------------------------------------- K_ssor = precon.ssor(S, 1.9) t1 = time.clock() x = numpy.zeros(n*n, 'd') info, iter, relres = itsolvers.pcg(S, b, x, tol, 2000, K_ssor) print 'info=%d, iter=%d, relres=%e' % (info, iter, relres) print 'Time for solving the system using SSS matrix and SSOR preconditioner: %8.2f sec' % (time.clock() - t1, )
src/m/a/matplotlib-HEAD/examples/pylab_examples/simple_plot_fps.py matplotlib(Download)
frames = 100.0
t = time.time()
c = time.clock()
for i in xrange(int(frames)):
part = i / frames
axis([0.0, 1.0 - part, -1.0 + part, 1.0 - part])
wallclock = time.time() - t
user = time.clock() - c
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next