Skip to content

Commit 1d4ca4a

Browse files
committed
Renamed runtime -> duration.
1 parent abe93c1 commit 1d4ca4a

File tree

6 files changed

+26
-22
lines changed

6 files changed

+26
-22
lines changed

lib/src/base/async_benchmark.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ Future<void> asyncReportMean(
3737
) async {
3838
final watch = Stopwatch()..start();
3939
final score = await instance.measure();
40-
final runtime = watch.elapsed.msus.style(ColorProfile.dim);
41-
emitter.emit('$runtime ${instance.description}', score);
40+
final duration = watch.elapsed.msus.style(ColorProfile.dim);
41+
emitter.emit('$duration ${instance.description}', score);
4242
}
4343

4444
// Generic function that reports benchmark scores by calling an emitter [E].
@@ -88,7 +88,7 @@ class AsyncBenchmark extends AsyncBenchmarkBase {
8888
/// Returns the benchmark description (corresponds to the getter name).
8989
String get description => name;
9090

91-
/// Runs [measure] and emits the score and benchmark runtime.
91+
/// Runs [measure] and emits the score and measured benchmark duration.
9292
@override
9393
Future<void> report() async {
9494
await asyncReportMean(this, emitter as ColorPrintEmitter);
@@ -165,7 +165,7 @@ class AsyncBenchmark extends AsyncBenchmarkBase {
165165
watch.stop();
166166
//stats.removeOutliers(10);
167167
return Score(
168-
runtime: watch.elapsed,
168+
duration: watch.elapsed,
169169
sample: sample.scores,
170170
innerIter: sample.innerIter,
171171
);
@@ -269,7 +269,7 @@ Future<void> asyncBenchmark<E extends ColorPrintEmitter>(
269269
error,
270270
stack,
271271
description: instance.description,
272-
runtime: watch.elapsed,
272+
duration: watch.elapsed,
273273
errorMark: benchmarkError,
274274
);
275275
}
@@ -280,7 +280,7 @@ Future<void> asyncBenchmark<E extends ColorPrintEmitter>(
280280
error,
281281
stack,
282282
description: instance.description,
283-
runtime: watch.elapsed,
283+
duration: watch.elapsed,
284284
errorMark: benchmarkError,
285285
);
286286
}),

lib/src/base/benchmark.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ void reportMean(Benchmark instance, ColorPrintEmitter emitter) {
3030
final watch = Stopwatch()..start();
3131
final value = instance.measure();
3232
watch.stop();
33-
final runtime = watch.elapsed.msus.style(ColorProfile.dim);
34-
emitter.emit('$runtime ${instance.description}', value);
33+
final duration = watch.elapsed.msus.style(ColorProfile.dim);
34+
emitter.emit('$duration ${instance.description}', value);
3535
}
3636

3737
/// Generic function that reports benchmark scores by calling an emitter [E].
@@ -146,7 +146,7 @@ class Benchmark extends BenchmarkBase {
146146
final watch = Stopwatch()..start();
147147
final sample = this.sample();
148148
return Score(
149-
runtime: watch.elapsed,
149+
duration: watch.elapsed,
150150
sample: sample.scores,
151151
innerIter: sample.innerIter,
152152
);
@@ -196,7 +196,7 @@ void benchmark<E extends ColorPrintEmitter>(
196196
error,
197197
stack,
198198
description: instance.description,
199-
runtime: watch.elapsed,
199+
duration: watch.elapsed,
200200
errorMark: benchmarkError,
201201
);
202202
return;
@@ -233,7 +233,7 @@ void benchmark<E extends ColorPrintEmitter>(
233233
error,
234234
stack,
235235
description: instance.description,
236-
runtime: watch.elapsed,
236+
duration: watch.elapsed,
237237
errorMark: benchmarkError,
238238
);
239239
}
@@ -244,7 +244,7 @@ void benchmark<E extends ColorPrintEmitter>(
244244
error,
245245
stack,
246246
description: instance.description,
247-
runtime: watch.elapsed,
247+
duration: watch.elapsed,
248248
errorMark: benchmarkError,
249249
);
250250
}),

lib/src/base/group.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Group {
4141
error,
4242
stack,
4343
description: description,
44-
runtime: watch.elapsed,
44+
duration: watch.elapsed,
4545
errorMark: groupErrorMark,
4646
);
4747
}
@@ -52,7 +52,7 @@ class Group {
5252
error,
5353
stack,
5454
description: description,
55-
runtime: watch.elapsed,
55+
duration: watch.elapsed,
5656
errorMark: groupErrorMark,
5757
);
5858
}),
@@ -71,7 +71,7 @@ class Group {
7171
error,
7272
stack,
7373
description: description,
74-
runtime: watch.elapsed,
74+
duration: watch.elapsed,
7575
errorMark: groupErrorMark,
7676
);
7777
}),

lib/src/base/score.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import '../util/stats.dart';
22

3-
/// Object holding sample stats and the sample generation runtime.
3+
/// Object holding sample stats and the duration it took to generate the
4+
/// score sample.
45
class Score<T extends num> {
56
Score(
6-
{required this.runtime, required List<T> sample, required this.innerIter})
7+
{required this.duration,
8+
required List<T> sample,
9+
required this.innerIter})
710
: stats = Stats(sample);
811

9-
/// Micro-benchmark duration
10-
final Duration runtime;
12+
/// Measured micro-benchmark duration
13+
final Duration duration;
1114

1215
/// Indicates if the a sample point was averaged over [iter] runs.
1316
final int innerIter;

lib/src/emitter/color_print_emitter.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ColorPrintEmitter extends PrintEmitter {
2828
}) {
2929
//final indentCharacters = score.runtime.msus.length;
3030
final indent = ' ';
31-
final part1 = '${score.runtime.msus.style(ColorProfile.dim)} $description';
31+
final part1 = '${score.duration.msus.style(ColorProfile.dim)} $description';
3232

3333
final mean = score.stats.mean / score.timeScale.factor;
3434
final stdDev = score.stats.stdDev / score.timeScale.factor;

lib/src/extension/string_utils.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,16 @@ void addSuccessMark([String mark = successMark]) {
2727
}
2828

2929
/// Reports an error and adds an error mark
30+
/// [duration] refers to the measured benchmark duration.
3031
void reportError(
3132
error,
3233
StackTrace stack, {
3334
required String description,
34-
required Duration runtime,
35+
required Duration duration,
3536
required String errorMark,
3637
}) {
3738
print(
38-
'${runtime.ssms.style(ColorProfile.dim)} '
39+
'${duration.ssms.style(ColorProfile.dim)} '
3940
'$description'
4041
'${errorMark == groupErrorMark ? ':' : ''} '
4142
'${error.toString().style(ColorProfile.error)}\n ',

0 commit comments

Comments
 (0)