Skip to content

Commit 200cf85

Browse files
committed
Format.
1 parent 3bc1120 commit 200cf85

12 files changed

+119
-62
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
2+
## 2.0.2
3+
- Updated dependencies.
4+
- Applied suggested lints.
5+
16
## 2.0.1
27
- Simplified methods `measure` and `measureAsync`.
3-
- Added `README.md` to folder `gnuplot`.
8+
- Added `README.md` to folder `gnuplot`.
49

510
## 2.0.0
611
Breaking changes:

lib/src/base/async_benchmark.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import 'sample_size.dart';
1717
/// * [runInIsolate]: Set to `true` to run benchmark in a
1818
/// separate isolate.
1919
/// * [scoreEmitter]: A custom score emitter.
20-
/// * [warmUpRuns]: The number of times [run] is called before the measurement.
2120
/// * [warmUpDuration]: The duration used to create a score estimate.
2221
/// * [sampleSize]: An optional parameter of type [SampleSize] that is used
2322
/// to specify the
@@ -35,8 +34,9 @@ Future<void> asyncBenchmark(
3534
bool runInIsolate = true,
3635
}) async {
3736
final group = Zone.current[#group] as Group?;
38-
final groupDescription =
39-
group == null ? '' : '${group.description.addSeparator(':')} ';
37+
final groupDescription = group == null
38+
? ''
39+
: '${group.description.addSeparator(':')} ';
4040

4141
final scoreGenerator = AsyncScoreGenerator(
4242
run: run,

lib/src/base/async_score_generator.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,11 @@ class AsyncScoreGenerator {
7878
// Rescale to microseconds.
7979
// Note: frequency is expressed in Hz (ticks/second).
8080
return (
81-
scores:
82-
sample
83-
.map<double>(
84-
(e) => e * (Duration.microsecondsPerSecond / watch.frequency),
85-
)
86-
.toList(),
81+
scores: sample
82+
.map<double>(
83+
(e) => e * (Duration.microsecondsPerSecond / watch.frequency),
84+
)
85+
.toList(),
8786
innerIterations: sampleSize.innerIterations,
8887
);
8988
} finally {

lib/src/base/benchmark.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ void benchmark(
2929
SampleSize? sampleSize,
3030
}) {
3131
final group = Zone.current[#group] as Group?;
32-
var groupDescription =
33-
group == null ? '' : '${group.description.addSeparator(':')} ';
32+
var groupDescription = group == null
33+
? ''
34+
: '${group.description.addSeparator(':')} ';
3435
final scoreGenerator = ScoreGenerator(
3536
run: run,
3637
setup: setup,

lib/src/base/benchmark_process_result.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ class BenchmarkProcessResult {
3131
/// `--define=isBenchmarkProcess=true`.
3232
String command({bool isBrief = true}) {
3333
final args = switch (isBrief) {
34-
true => arguments
35-
.where((arg) => arg != '--define=isBenchmarkProcess=true')
36-
.join(' '),
34+
true =>
35+
arguments
36+
.where((arg) => arg != '--define=isBenchmarkProcess=true')
37+
.join(' '),
3738
false => arguments.join(' '),
3839
};
3940
return executable +

lib/src/base/score_generator.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,11 @@ class ScoreGenerator {
6868
// Rescale to microseconds.
6969
// Note: frequency is expressed in Hz (ticks/second).
7070
return (
71-
scores:
72-
sample
73-
.map<double>(
74-
(e) => e * (Duration.microsecondsPerSecond / watch.frequency),
75-
)
76-
.toList(),
71+
scores: sample
72+
.map<double>(
73+
(e) => e * (Duration.microsecondsPerSecond / watch.frequency),
74+
)
75+
.toList(),
7776
innerIterations: sampleSize.innerIterations,
7877
);
7978
} finally {

lib/src/command/export_command.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ class ExportCommand extends ReportCommand {
5454

5555
Ansi.status = isMonochrome ? AnsiOutput.disabled : AnsiOutput.enabled;
5656

57-
final searchDirectory =
58-
argResults!.rest.isEmpty ? 'benchmark' : argResults!.rest.first;
57+
final searchDirectory = argResults!.rest.isEmpty
58+
? 'benchmark'
59+
: argResults!.rest.first;
5960

6061
final benchmarkFiles = await findBenchmarkFiles();
6162

lib/src/command/report_command.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,13 @@ class ReportCommand extends Command {
4343
/// * Uses `argResults!.rest.first` as path.
4444
/// * If no path is provided, the directory `benchmark` is used.
4545
Future<List<File>> findBenchmarkFiles() async {
46-
final searchDirectory =
47-
argResults!.rest.isEmpty ? 'benchmark' : argResults!.rest.first;
46+
final searchDirectory = argResults!.rest.isEmpty
47+
? 'benchmark'
48+
: argResults!.rest.first;
4849

4950
// Resolving test files.
50-
final (
51-
benchmarkFiles: benchmarkFiles,
52-
entityType: entityType,
53-
) = await resolveBenchmarkFiles(searchDirectory);
51+
final (benchmarkFiles: benchmarkFiles, entityType: entityType) =
52+
await resolveBenchmarkFiles(searchDirectory);
5453
if (benchmarkFiles.isEmpty) {
5554
print('');
5655
print(

lib/src/extension/benchmark_helper.dart

Lines changed: 70 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -164,37 +164,87 @@ extension BenchmarkHelper on Stopwatch {
164164
return switch (scoreInMicroseconds) {
165165
< t1n1 => SampleSize(length: s1n1, innerIterations: i1n1), // 1 us
166166
> t1n1 && <= t1e0 => SampleSize(
167-
length:
168-
interpolateExp(scoreInMicroseconds, t1n1, s1n1, t1e0, s1e0).ceil(),
169-
innerIterations:
170-
interpolateExp(scoreInMicroseconds, t1n1, i1n1, t1e0, i1e0).ceil(),
167+
length: interpolateExp(
168+
scoreInMicroseconds,
169+
t1n1,
170+
s1n1,
171+
t1e0,
172+
s1e0,
173+
).ceil(),
174+
innerIterations: interpolateExp(
175+
scoreInMicroseconds,
176+
t1n1,
177+
i1n1,
178+
t1e0,
179+
i1e0,
180+
).ceil(),
171181
), // 1 us
172182
> t1e0 && <= t1e1 => SampleSize(
173-
length:
174-
interpolateExp(scoreInMicroseconds, t1e0, s1e0, t1e1, s1e1).ceil(),
175-
innerIterations:
176-
interpolateExp(scoreInMicroseconds, t1e0, i1e0, t1e1, i1e1).ceil(),
183+
length: interpolateExp(
184+
scoreInMicroseconds,
185+
t1e0,
186+
s1e0,
187+
t1e1,
188+
s1e1,
189+
).ceil(),
190+
innerIterations: interpolateExp(
191+
scoreInMicroseconds,
192+
t1e0,
193+
i1e0,
194+
t1e1,
195+
i1e1,
196+
).ceil(),
177197
), // 10 us
178198
> t1e1 && <= t1e2 => SampleSize(
179-
length:
180-
interpolateExp(scoreInMicroseconds, t1e1, s1e1, t1e2, s1e2).ceil(),
181-
innerIterations:
182-
interpolateExp(scoreInMicroseconds, t1e1, i1e1, t1e2, i1e2).ceil(),
199+
length: interpolateExp(
200+
scoreInMicroseconds,
201+
t1e1,
202+
s1e1,
203+
t1e2,
204+
s1e2,
205+
).ceil(),
206+
innerIterations: interpolateExp(
207+
scoreInMicroseconds,
208+
t1e1,
209+
i1e1,
210+
t1e2,
211+
i1e2,
212+
).ceil(),
183213
), // 100 us
184214
> t1e2 && <= t1e3 => SampleSize(
185-
length:
186-
interpolateExp(scoreInMicroseconds, t1e2, s1e2, t1e3, s1e3).ceil(),
187-
innerIterations:
188-
interpolateExp(scoreInMicroseconds, t1e2, i1e2, t1e3, i1e3).ceil(),
215+
length: interpolateExp(
216+
scoreInMicroseconds,
217+
t1e2,
218+
s1e2,
219+
t1e3,
220+
s1e3,
221+
).ceil(),
222+
innerIterations: interpolateExp(
223+
scoreInMicroseconds,
224+
t1e2,
225+
i1e2,
226+
t1e3,
227+
i1e3,
228+
).ceil(),
189229
), // 1ms
190230
> t1e3 && <= t1e4 => SampleSize(
191-
length:
192-
interpolateExp(scoreInMicroseconds, t1e3, s1e3, t1e4, s1e4).ceil(),
231+
length: interpolateExp(
232+
scoreInMicroseconds,
233+
t1e3,
234+
s1e3,
235+
t1e4,
236+
s1e4,
237+
).ceil(),
193238
innerIterations: i1e4,
194239
), // 10 ms
195240
> t1e4 && <= t1e5 => SampleSize(
196-
length:
197-
interpolateExp(scoreInMicroseconds, t1e4, s1e4, t1e5, s1e5).ceil(),
241+
length: interpolateExp(
242+
scoreInMicroseconds,
243+
t1e4,
244+
s1e4,
245+
t1e5,
246+
s1e5,
247+
).ceil(),
198248
innerIterations: i1e5,
199249
), // 100 ms
200250
_ => SampleSize(length: s1e5, innerIterations: i1e5),

lib/src/extension/histogram.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ extension Histogram on Stats {
3333
int intervalNumber = -1,
3434
}) {
3535
final sampleSize = sortedSample.length;
36-
intervalNumber =
37-
intervalNumber < 3 ? intervalNumberFreedman : intervalNumber;
36+
intervalNumber = intervalNumber < 3
37+
? intervalNumberFreedman
38+
: intervalNumber;
3839

3940
final intervalSize = (max - min) / intervalNumber;
4041
final gridPoints = intervalNumber + 1;
@@ -127,8 +128,9 @@ extension Histogram on Stats {
127128
///
128129
///
129130
String blockHistogram({bool normalize = false, int intervalNumber = 0}) {
130-
intervalNumber =
131-
intervalNumber < 2 ? intervalNumberFreedman : intervalNumber;
131+
intervalNumber = intervalNumber < 2
132+
? intervalNumberFreedman
133+
: intervalNumber;
132134

133135
/// Make sure we have at least 2 intervals
134136
while (intervalNumber < 2) {

0 commit comments

Comments
 (0)