You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following code runs in ~1500ms on my machine, If I move the loops into a function and call it it is much faster ~90ms. This looks like an issue related to OSR. If I use rnd.length instead of rs in the inner loop limit, it is even slower ~2500ms.
Dart SDK version 1.2.0-dev.5.11, Unchecked mode.
import "dart:typed_data";
import "dart:math";
void main() {
int rs = 1 << 20;
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");
}
The text was updated successfully, but these errors were encountered:
I diagnosed the issue and the problem is that the current OSR support does not work well if a function contains multiple loops like the example: OSR is never triggered the second time, but it should be.
This issue was originally filed by @mdakin
Following code runs in ~1500ms on my machine, If I move the loops into a function and call it it is much faster ~90ms. This looks like an issue related to OSR. If I use rnd.length instead of rs in the inner loop limit, it is even slower ~2500ms.
Dart SDK version 1.2.0-dev.5.11, Unchecked mode.
import "dart:typed_data";
import "dart:math";
void main() {
int rs = 1 << 20;
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");
}
The text was updated successfully, but these errors were encountered: