Skip to content

Commit

Permalink
test(benchmarks) Lower N.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hywan committed Apr 13, 2019
1 parent ffc9cc1 commit f0a4499
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions benchmarks/test_nbody.py
Expand Up @@ -9,12 +9,14 @@
here = os.path.dirname(os.path.realpath(__file__))
TEST_BYTES = open(here + '/nbody.wasm', 'rb').read()

N = 5000

def test_benchmark_nbody_with_wasmer(benchmark):
instance = wasmer.Instance(TEST_BYTES)
nbody = instance.exports.main

def bench():
return nbody(5000000)
return nbody(N)

assert benchmark(bench)

Expand All @@ -23,7 +25,7 @@ def test_benchmark_nbody_with_ppci(benchmark):
nbody = instance.exports.main

def bench():
return nbody(5000000)
return nbody(N)

assert benchmark(bench)

Expand Down Expand Up @@ -116,7 +118,7 @@ def report_energy(bodies=SYSTEM, pairs=PAIRS, e=0.0):
e -= (m1 * m2) / ((dx * dx + dy * dy + dz * dz) ** 0.5)
for (r, [vx, vy, vz], m) in bodies:
e += m * (vx * vx + vy * vy + vz * vz) / 2.
print("%.9f" % e)
return e

def offset_momentum(ref, bodies=SYSTEM, px=0.0, py=0.0, pz=0.0):
for (r, [vx, vy, vz], m) in bodies:
Expand All @@ -132,9 +134,9 @@ def nbody(n, ref='sun'):
offset_momentum(BODIES[ref])
report_energy()
advance(0.01, n)
report_energy()
return report_energy()

def bench():
return nbody(5000000)
return nbody(N)

assert benchmark(bench)

0 comments on commit f0a4499

Please sign in to comment.