File tree 1 file changed +10
-7
lines changed
1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ time(name, body) {
8
8
print ('$name : => ${statMeasure (body )}' );
9
9
}
10
10
11
- statMeasure (body) {
11
+ StatSample statMeasure (body) {
12
12
var list = [];
13
13
var count = 100 ;
14
14
for (var i = 0 ; i < count; i++ ) {
@@ -18,11 +18,11 @@ statMeasure(body) {
18
18
return new StatSample (list);
19
19
}
20
20
21
- measure (b) {
21
+ Sample measure (b) {
22
22
// actual test;
23
23
var count = 0 ;
24
24
var stopwatch = new Stopwatch ();
25
- var targetTime = 50 * 1000 ;
25
+ var targetTime = 500 ;
26
26
stopwatch.start ();
27
27
do {
28
28
b ();
@@ -49,6 +49,9 @@ measure(b) {
49
49
b (); b (); b (); b (); b (); b (); b (); b (); b (); b (); // 8
50
50
b (); b (); b (); b (); b (); b (); b (); b (); b (); b (); // 9
51
51
}
52
+ for (var i = 0 ; i < count % 100 ; i++ ) {
53
+ b ();
54
+ }
52
55
}
53
56
stopwatch.stop ();
54
57
int elapsed = max (1 , stopwatch.elapsedMicroseconds);
@@ -98,12 +101,12 @@ class StatSample {
98
101
}
99
102
100
103
class Sample {
101
- num count;
102
- num time_us;
104
+ final num count;
105
+ final num time_us;
103
106
104
107
Sample (this .count, this .time_us);
105
108
106
- get rate => count / time_us;
109
+ num get rate => count / time_us;
107
110
108
- toString () => rate;
111
+ String toString () => '$ rate ' ;
109
112
}
You can’t perform that action at this time.
0 commit comments