Skip to content

Commit 4966572

Browse files
committed
chore(_perf.dart): lower the target time to prevent a memory overflow
1 parent b9a170f commit 4966572

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

benchmark/_perf.dart

+10-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ time(name, body) {
88
print('$name: => ${statMeasure(body)}');
99
}
1010

11-
statMeasure(body) {
11+
StatSample statMeasure(body) {
1212
var list = [];
1313
var count = 100;
1414
for(var i = 0; i < count; i++) {
@@ -18,11 +18,11 @@ statMeasure(body) {
1818
return new StatSample(list);
1919
}
2020

21-
measure(b) {
21+
Sample measure(b) {
2222
// actual test;
2323
var count = 0;
2424
var stopwatch = new Stopwatch();
25-
var targetTime = 50 * 1000;
25+
var targetTime = 500;
2626
stopwatch.start();
2727
do {
2828
b();
@@ -49,6 +49,9 @@ measure(b) {
4949
b(); b(); b(); b(); b(); b(); b(); b(); b(); b(); // 8
5050
b(); b(); b(); b(); b(); b(); b(); b(); b(); b(); // 9
5151
}
52+
for(var i = 0; i < count % 100; i++) {
53+
b();
54+
}
5255
}
5356
stopwatch.stop();
5457
int elapsed = max(1, stopwatch.elapsedMicroseconds);
@@ -98,12 +101,12 @@ class StatSample {
98101
}
99102

100103
class Sample {
101-
num count;
102-
num time_us;
104+
final num count;
105+
final num time_us;
103106

104107
Sample(this.count, this.time_us);
105108

106-
get rate => count / time_us;
109+
num get rate => count / time_us;
107110

108-
toString() => rate;
111+
String toString() => '$rate';
109112
}

0 commit comments

Comments
 (0)