@@ -38,14 +38,14 @@ extension BenchmarkHelper on Stopwatch {
3838
3939 /// Measures the runtime of [f] for [duration] and
4040 /// reports the average runtime expressed as clock ticks.
41- ({int ticks, int iter}) warmup (
41+ ({int ticks, int iter}) warmUp (
4242 void Function () f, {
4343 Duration duration = const Duration (milliseconds: 200 ),
44- int preRuns = 3 ,
44+ int warmUpRuns = 3 ,
4545 }) {
46- var ticks = microsecondsToTicks (duration.inMicroseconds );
47- var iter = 0 ;
48- for (var i = 0 ; i < preRuns ; i++ ) {
46+ int ticks = durationToTicks (duration);
47+ int iter = 0 ;
48+ for (var i = 0 ; i < warmUpRuns ; i++ ) {
4949 f ();
5050 }
5151 reset ();
@@ -59,15 +59,15 @@ extension BenchmarkHelper on Stopwatch {
5959
6060 /// Measures the runtime of [f] for [duration] and
6161 /// reports the average runtime expressed as clock ticks.
62- Future <({int ticks, int iter})> warmupAsync (
62+ Future <({int ticks, int iter})> warmUpAsync (
6363 Future <void > Function () f, {
6464 Duration duration = const Duration (milliseconds: 200 ),
65- int preRuns = 3 ,
65+ int warmUpRuns = 3 ,
6666 }) async {
67- var ticks = microsecondsToTicks (duration.inMicroseconds );
68- var iter = 0 ;
67+ int ticks = durationToTicks (duration);
68+ int iter = 0 ;
6969 reset ();
70- for (var i = 0 ; i < preRuns ; i++ ) {
70+ for (var i = 0 ; i < warmUpRuns ; i++ ) {
7171 await f ();
7272 }
7373 start ();
@@ -84,6 +84,10 @@ extension BenchmarkHelper on Stopwatch {
8484 /// Converts clock [ticks] to seconds.
8585 static double ticksToSeconds (int ticks) => ticks / BenchmarkHelper .frequency;
8686
87+ /// Convert [duration] to clock ticks.
88+ static int durationToTicks (Duration duration) =>
89+ microsecondsToTicks (duration.inMicroseconds);
90+
8791 /// Converts clock [ticks] to microseconds.
8892 static double ticksToMicroseconds (int ticks) =>
8993 ticks / (BenchmarkHelper .frequency / 1000000 );
@@ -124,8 +128,8 @@ extension BenchmarkHelper on Stopwatch {
124128 /// * number of runs each score is averaged over: `.inner` .
125129 ///
126130 /// Note: An estimate of the benchmark runtime in clock ticks is given by
127- /// `outer*inner*clockTicks` . The estimate does not include any setup, warmup,
128- /// or teardown functionality.
131+ /// `outer*inner*clockTicks` . The estimate does not include any setup,
132+ /// warm-up, or teardown functionality.
129133 static ({int outer, int inner}) sampleSizeDefault (int clockTicks) {
130134 // Estimates for the averaging used within `measure` and `measureAsync.
131135
0 commit comments