benchmark method
Implementation
void benchmark(String name, double ms) {
double msb = ms / 3;
int t = DateTime.now().millisecondsSinceEpoch;
int d1 = 0;
int d2 = 0;
int d3 = 0;
int n = 0;
while (DateTime.now().millisecondsSinceEpoch - t < msb) {
noise1((n++).toDouble());
d1++;
}
t = DateTime.now().millisecondsSinceEpoch;
while (DateTime.now().millisecondsSinceEpoch - t < msb) {
noise2((n++).toDouble(), (n++).toDouble());
d2++;
}
t = DateTime.now().millisecondsSinceEpoch;
while (DateTime.now().millisecondsSinceEpoch - t < msb) {
noise3((n++).toDouble(), (n++).toDouble(), (n++).toDouble());
d3++;
}
print(name +
": " +
"1D: " +
(d1 / msb).round().toString() +
"/ms " +
"2D: " +
(d2 / msb).round().toString() +
"/ms " +
"3D: " +
(d3 / msb).round().toString() +
"/ms");
}