コード例 #1
0
ファイル: overhead.py プロジェクト: M0nd4/lattice-gas

steps = range(1, 201)
Trun = []
Tpy = []
Tc = []
for i in steps:
    print i
    t1 = time()
    for j in xrange(i):
        sys.whole_lattice()
    t2 = time()
    Tpy.append(1000*(t2-t1))
    t1 = time()
    sys.run(i)
    t2 = time()
    Trun.append(1000*(t2-t1))
    t1 = time()
    sys.crun(i)
    t2 = time()
    Tc.append(1000*(t2-t1))
steps = array(steps)
Trun = array(Trun)
Tpy = array(Tpy)
Tc = array(Tc)
plot(steps, Tpy/steps, steps, Trun/steps, steps, Tc/steps)
legend(["Python stripped", "Python", "c"])
xlabel("Run length")
ylabel("Time per step [ms]")
show()
コード例 #2
0
sys.set_T(20.0)

steps = range(1, 201)
Trun = []
Tpy = []
Tc = []
for i in steps:
    print i
    t1 = time()
    for j in xrange(i):
        sys.whole_lattice()
    t2 = time()
    Tpy.append(1000 * (t2 - t1))
    t1 = time()
    sys.run(i)
    t2 = time()
    Trun.append(1000 * (t2 - t1))
    t1 = time()
    sys.crun(i)
    t2 = time()
    Tc.append(1000 * (t2 - t1))
steps = array(steps)
Trun = array(Trun)
Tpy = array(Tpy)
Tc = array(Tc)
plot(steps, Tpy / steps, steps, Trun / steps, steps, Tc / steps)
legend(["Python stripped", "Python", "c"])
xlabel("Run length")
ylabel("Time per step [ms]")
show()