Skip to content

Commit 67b4ded

Browse files
Benchmark: rename measurements so relations are more obvious.
1 parent c98dd27 commit 67b4ded

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

benchmark/lib/benchmark.dart

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ class Benchmark {
3030
Benchmark(this.name, {this.iterations = 1, this.coefficient = 1})
3131
: emitter = Emitter(iterations, coefficient) {
3232
print('-------------------------------------------------------------');
33-
print('$name(iterations): ' +
33+
print('$name(iterations): ' +
3434
Emitter._format(iterations.toDouble(), decimalPoints: 0));
35-
print('$name(count): ' +
35+
print('$name(unit count): ' +
3636
Emitter._format(iterations / coefficient, decimalPoints: 0));
3737
// Measure the total time of the test - if it's too high, you should
3838
// decrease the number of iterations. Expected time is between 2 and 3 sec.
@@ -50,7 +50,7 @@ class Benchmark {
5050
void teardown() {
5151
final millis = watch.elapsedMilliseconds;
5252
final color = millis > 3000 ? '\x1B[31m' : '';
53-
print('$name(total time taken): '
53+
print('$name(benchmark run time): '
5454
'$color${Emitter._format(millis.toDouble(), suffix: ' ms')}\x1B[0m');
5555
}
5656

@@ -117,12 +117,14 @@ class Emitter {
117117
void emit(String testName, double value) {
118118
final timePerIter = value / iterations;
119119
final timePerUnit = timePerIter * coefficient;
120-
print(
121-
'$testName(Single iteration): ${_format(timePerIter, suffix: ' us')}');
122-
print(
123-
'$testName(Runtime per unit): ${_format(timePerUnit, suffix: ' us')}');
124-
print('$testName(Runs per second): ${_format(usInSec / timePerIter)}');
125-
print('$testName(Units per second): ${_format(usInSec / timePerUnit)}');
120+
print('$testName(single iteration): '
121+
'${_format(timePerIter, suffix: ' us')}');
122+
print('$testName(per unit): '
123+
'${_format(timePerUnit, suffix: ' us')}');
124+
print('$testName(iterations / second): '
125+
'${_format(usInSec / timePerIter)}');
126+
print('$testName(units / second): '
127+
'${_format(usInSec / timePerUnit)}');
126128
}
127129

128130
// Simple number formatting, maybe use a lib?

0 commit comments

Comments
 (0)