Created
February 20, 2014 07:09
-
-
Save mdakin/9108419 to your computer and use it in GitHub Desktop.
Typed array performance 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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