/mobile Handheld Friendly website
x64 Ubuntu : Intel® Q6600® quad-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 |
|---|---|---|---|---|---|
| 1,000 | 0.55 | 0.59 | 7,080 | 809 | 21% 58% 28% 19% |
| 4,000 | 4.21 | 1.76 | 84,652 | 809 | 35% 33% 76% 95% |
| 16,000 | 56.25 | 20.58 | 212,724 | 809 | 53% 39% 99% 83% |
Read the ↓ make, command line, and program output logs to see how this program was run.
Read mandelbrot benchmark to see what this program should do.
Dart VM version: 0.4.7.1_r21537 (Tue Apr 16 01:34:51 2013)
/* The Computer Language Benchmarks Game http://benchmarksgame.alioth.debian.org/ contributed by Jos Hirth, calculation block borrowed from the C# version which was created by Isaac Gouy, Antti Lankila, The Anh Tran, and Robert F. Tobler */ import 'dart:io'; import 'dart:isolate'; import 'dart:async'; import 'dart:typeddata'; void main() { int n = ((){ var args = new Options().arguments; return args.length > 0 ? int.parse(args[0]) : 200; }()); var threads = Platform.numberOfProcessors; var ports = new List(threads); var segmentFutures = new List(threads); int lineLen = (n - 1) ~/ 8 + 1; var lines = new List<Int8List>(n); var segmentSize = new List.filled(threads, n ~/ threads); segmentSize[0] += n % threads; var from = 0; for (int i = 0; i < threads; i++) { var len = segmentSize[i]; ports[i] = spawnFunction(calculateSegment); segmentFutures[i] = ports[i].call({ 'n': n, 'from': from, 'len': len }); from += len; } stdout.write('P4\n$n $n\n'); Future.wait(segmentFutures).then((segments) { for (var segment in segments) { for (var line in segment) { stdout.add(line); } } }); } Int8List calculateLine (int n, int y) { int lineLen = (n - 1) ~/ 8 + 1; var line = new Int8List(lineLen); int xbyte = 0, bits = 1; double ci = y * 2.0 / n - 1.0; for (int x = 0; x < n; x++) { double cr = x * 2.0 / n - 1.5; if (bits > 0xff) { line[xbyte++] = bits; bits = 1; } double zr = cr, zi = ci, tr = cr * cr, ti = ci * ci; int i = 49; do { zi = zr * zi + zr * zi + ci; zr = tr - ti + cr; tr = zr * zr; ti = zi * zi; } while ((tr + ti <= 4.0) && (--i > 0)); bits = (bits << 1) | (i == 0 ? 1 : 0); } while (bits < 0x100) bits = (bits << 1); line[xbyte] = bits; return line; } void calculateSegment () { port.receive((msg, replyTo) { int n = msg['n']; int from = msg['from']; int len = msg['len']; var lines = new List<Int8List>(len); for (int i = 0; i < len; i++) { lines[i] = calculateLine(n, from + i); } replyTo.send(lines); }); }
Sun, 21 Apr 2013 16:26:15 GMT COMMAND LINE: /usr/local/src/dart-sdk/bin/dart mandelbrot.dart 16000 (BINARY) PROGRAM OUTPUT NOT SHOWN