/mobile Handheld Friendly website
Ubuntu : Intel® Q6600® one core |
Each table row shows performance measurements for this Dart program with a particular command-line input value N.
| N | CPU secs | Elapsed secs | Memory KB | Code B | ≈ CPU Load |
|---|---|---|---|---|---|
| 500,000 | 0.98 | 0.98 | 38,840 | 1297 | 0% 0% 3% 100% |
| 5,000,000 | 10.57 | 10.58 | 38,840 | 1297 | 0% 1% 0% 100% |
| 50,000,000 | 93.21 | 93.33 | 38,840 | 1297 | 0% 0% 0% 100% |
Read the ↓ make, command line, and program output logs to see how this program was run.
Read n-body benchmark to see what this program should do.
Dart VM version: 0.4.7.1_r21537 (Tue Apr 16 01:34:29 2013)
"The Dart team has provided an official benchmark harness that ensures your benchmark follows the benchmarking procedures necessary for the Dart VM’s optimizer."
Here are the measurements reported from benchmark_harness.dart with n=500000 n=5000000 n=50000000 on x64q
Template(RunTime): 8295000.0 us. Template(RunTime): 84912000.0 us. Template(RunTime): 837669000.0 us.
Which is actually --
0.83 secs 8.49 secs 83.77 secs
/* The Computer Language Benchmarks Game http://benchmarksgame.alioth.debian.org/ contributed by Jos Hirth, transliterated from Isaac Gouy and Robert F. Tobler's C# program */ import 'dart:io'; import 'dart:math' as Math; void main() { int n = () { var args = new Options().arguments; return args.length > 0 ? int.parse(args[0]) : 0; }(); NBodySystem system = new NBodySystem(); print(system.energy().toStringAsFixed(9)); for (int i = 0; i < n; i++) { system.advance(0.01); } print(system.energy().toStringAsFixed(9)); } class Body { double x, y, z, vx, vy, vz, mass; Body({this.x, this.y, this.z, this.vx, this.vy, this.vz, this.mass}); } class NBodySystem { var bodies; const double solarmass = 4 * Math.PI * Math.PI; const double daysPeryear = 365.24; NBodySystem() { bodies = new List<Body>(); bodies.addAll([ // Sun new Body( x: 0.0, y: 0.0, z: 0.0, vx: 0.0, vy: 0.0, vz: 0.0, mass: solarmass ), // Jupiter new Body( x: 4.84143144246472090e+00, y: -1.16032004402742839e+00, z: -1.03622044471123109e-01, vx: 1.66007664274403694e-03 * daysPeryear, vy: 7.69901118419740425e-03 * daysPeryear, vz: -6.90460016972063023e-05 * daysPeryear, mass: 9.54791938424326609e-04 * solarmass ), // Saturn new Body( x: 8.34336671824457987e+00, y: 4.12479856412430479e+00, z: -4.03523417114321381e-01, vx: -2.76742510726862411e-03 * daysPeryear, vy: 4.99852801234917238e-03 * daysPeryear, vz: 2.30417297573763929e-05 * daysPeryear, mass: 2.85885980666130812e-04 * solarmass ), // Uranus new Body( x: 1.28943695621391310e+01, y: -1.51111514016986312e+01, z: -2.23307578892655734e-01, vx: 2.96460137564761618e-03 * daysPeryear, vy: 2.37847173959480950e-03 * daysPeryear, vz: -2.96589568540237556e-05 * daysPeryear, mass: 4.36624404335156298e-05 * solarmass ), // Neptune new Body( x: 1.53796971148509165e+01, y: -2.59193146099879641e+01, z: 1.79258772950371181e-01, vx: 2.68067772490389322e-03 * daysPeryear, vy: 1.62824170038242295e-03 * daysPeryear, vz: -9.51592254519715870e-05 * daysPeryear, mass: 5.15138902046611451e-05 * solarmass ) ]); double px = 0.0, py = 0.0, pz = 0.0; for (var b in bodies) { px += b.vx * b.mass; py += b.vy * b.mass; pz += b.vz * b.mass; }; var sol = bodies[0]; sol.vx = -px / solarmass; sol.vy = -py / solarmass; sol.vz = -pz / solarmass; } void advance(double dt) { for(int na = 0; na < bodies.length; na++){ Body a = bodies[na]; for(int nb = na + 1; nb < bodies.length; nb++){ Body b = bodies[nb]; double dx = a.x - b.x, dy = a.y - b.y, dz = a.z - b.z; double d2 = dx * dx + dy * dy + dz * dz; double mag = dt / (d2 * Math.sqrt(d2)); a.vx -= dx * b.mass * mag; b.vx += dx * a.mass * mag; a.vy -= dy * b.mass * mag; b.vy += dy * a.mass * mag; a.vz -= dz * b.mass * mag; b.vz += dz * a.mass * mag; } } for (var b in bodies) { b.x += dt * b.vx; b.y += dt * b.vy; b.z += dt * b.vz; } } double energy() { double e = 0.0; for (int i = 0; i < bodies.length; i++) { var bi = bodies[i]; e += 0.5 * bi.mass * ( bi.vx * bi.vx + bi.vy * bi.vy + bi.vz * bi.vz); for (int j = i + 1; j < bodies.length; j++) { var bj = bodies[j]; double dx = bi.x - bj.x, dy = bi.y - bj.y, dz = bi.z - bj.z; e -= (bi.mass * bj.mass) / Math.sqrt(dx * dx + dy * dy + dz * dz); } } return e; } }
Thu, 18 Apr 2013 04:08:06 GMT COMMAND LINE: /usr/local/src/dart-sdk/bin/dart nbody.dart-2.dart 50000000 PROGRAM OUTPUT: -0.169075164 -0.169059907