Skip to content

Instantly share code, notes, and snippets.

@mdakin
Created February 20, 2014 07:09
Show Gist options
  • Save mdakin/9108419 to your computer and use it in GitHub Desktop.
Save mdakin/9108419 to your computer and use it in GitHub Desktop.
Typed array performance 1
import "dart:typed_data";
import "dart:math";
void main() {
int rs = 1000000;
int iter = 50;
Float64List rnd = new Float64List(rs);
Random r = new Random(1);
for (int i = 0; i < rs; i++) {
rnd[i] = r.nextDouble() * PI;
}
Stopwatch sw = new Stopwatch();
sw.start();
double total = 0.0;
for (int j = 0; j < iter; j++) {
for (int i = 0; i < rs; i++) {
total += rnd[i];
}
}
var e = sw.elapsedMilliseconds;
print("Time: $e");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment