Skip to content

Commit ff87171

Browse files
munificentCommit Queue
authored and
Commit Queue
committed
Reformat benchmarks/ with 3.8 style.
Change-Id: Ied900f7d85addabc586823139aa78b879be035ea Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425182 Auto-Submit: Bob Nystrom <[email protected]> Reviewed-by: Lasse Nielsen <[email protected]> Commit-Queue: Lasse Nielsen <[email protected]>
1 parent 237ba8d commit ff87171

File tree

13 files changed

+150
-166
lines changed

13 files changed

+150
-166
lines changed

benchmarks/BigIntParsePrint/dart/BigIntParsePrint.dart

+4-5
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,10 @@ void main() {
335335

336336
// Warm up all benchmarks to ensure consistent behavior of shared code.
337337
benchmarks.forEach(
338-
(bm) =>
339-
bm()
340-
..setup()
341-
..run()
342-
..run(),
338+
(bm) => bm()
339+
..setup()
340+
..run()
341+
..run(),
343342
);
344343

345344
benchmarks.forEach((bm) => bm().report());

benchmarks/FileIOSink/dart/FileIOSink.dart

+3-4
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,9 @@ class BenchmarkAlternatingSizedAdd extends AsyncBenchmarkBase {
8383
@override
8484
Future<void> setup() async {
8585
_tempDir = Directory.systemTemp.createTempSync();
86-
_ioSink =
87-
File(
88-
_tempDir.uri.resolve('alternative-add-size').toFilePath(),
89-
).openWrite();
86+
_ioSink = File(
87+
_tempDir.uri.resolve('alternative-add-size').toFilePath(),
88+
).openWrite();
9089
}
9190

9291
@override

benchmarks/Isolate/dart/Isolate.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ class SendReceiveHelper {
5454
port = ReceivePort();
5555
inbox = StreamIterator<dynamic>(port);
5656
workerCompleted = Completer<bool>();
57-
workerExitedPort =
58-
ReceivePort()..listen((_) => workerCompleted.complete(true));
57+
workerExitedPort = ReceivePort()
58+
..listen((_) => workerCompleted.complete(true));
5959
worker = await Isolate.spawn(
6060
isolate,
6161
StartMessage(port.sendPort, useTransferable, size),

benchmarks/IsolateJson/dart/IsolateJson.dart

+3-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ class BenchmarkConfig {
118118
}
119119

120120
Future<void> main() async {
121-
final jsonString =
122-
File('benchmarks/IsolateJson/dart/sample.json').readAsStringSync();
121+
final jsonString = File(
122+
'benchmarks/IsolateJson/dart/sample.json',
123+
).readAsStringSync();
123124
final json250KB = utf8.encode(jsonString); // 294356 bytes
124125
final decoded = json.decode(utf8.decode(json250KB));
125126
final decoded1MB = <dynamic, dynamic>{

benchmarks/IsolateSpawn/dart/IsolateSpawn.dart

+15-11
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ class SpawnLatency {
1515
final completerResult = Completer();
1616
final receivePort = ReceivePort()..listen(completerResult.complete);
1717
final isolateExitedCompleter = Completer<DateTime>();
18-
final onExitReceivePort =
19-
ReceivePort()..listen((_) {
20-
isolateExitedCompleter.complete(DateTime.now());
21-
});
18+
final onExitReceivePort = ReceivePort()
19+
..listen((_) {
20+
isolateExitedCompleter.complete(DateTime.now());
21+
});
2222
final beforeSpawn = DateTime.now();
2323
await Isolate.spawn(
2424
isolateCompiler,
@@ -32,8 +32,9 @@ class SpawnLatency {
3232
receivePort.close();
3333
final DateTime isolateExited = await isolateExitedCompleter.future;
3434
result.timeToExitUs = isolateExited.difference(beforeSpawn).inMicroseconds;
35-
result.timeToIsolateSpawnUs =
36-
afterSpawn.difference(beforeSpawn).inMicroseconds;
35+
result.timeToIsolateSpawnUs = afterSpawn
36+
.difference(beforeSpawn)
37+
.inMicroseconds;
3738
onExitReceivePort.close();
3839

3940
return result;
@@ -139,7 +140,8 @@ class AggregatedResultMessageLatency {
139140
);
140141

141142
@override
142-
String toString() => '''$toAfterIsolateSpawnUs
143+
String toString() =>
144+
'''$toAfterIsolateSpawnUs
143145
$toStartRunningCodeUs
144146
$toFinishRunningCodeUs
145147
$toExitUs''';
@@ -164,10 +166,12 @@ Future<void> isolateCompiler(StartMessageLatency start) async {
164166
final timeFinishRunningCodeUs = DateTime.now();
165167
start.sendPort.send(
166168
ResultMessageLatency(
167-
timeToStartRunningCodeUs:
168-
timeRunningCodeUs.difference(start.spawned).inMicroseconds,
169-
timeToFinishRunningCodeUs:
170-
timeFinishRunningCodeUs.difference(start.spawned).inMicroseconds,
169+
timeToStartRunningCodeUs: timeRunningCodeUs
170+
.difference(start.spawned)
171+
.inMicroseconds,
172+
timeToFinishRunningCodeUs: timeFinishRunningCodeUs
173+
.difference(start.spawned)
174+
.inMicroseconds,
171175
),
172176
);
173177
}

benchmarks/MapCopy/dart/MapCopy.dart

+6-8
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,12 @@ void pollute() {
224224
final Map<String, Object> m2 = HashMap.of(m1);
225225
final Map<int, Object> m3 = Map.of({1: 66});
226226
final Map<int, Object> m4 = HashMap.of({1: 66});
227-
final Map<Object, Object> m5 =
228-
Map.identity()
229-
..[Thing()] = 1
230-
..[Thing()] = 2;
231-
final Map<Object, Object> m6 =
232-
HashMap.identity()
233-
..[Thing()] = 1
234-
..[Thing()] = 2;
227+
final Map<Object, Object> m5 = Map.identity()
228+
..[Thing()] = 1
229+
..[Thing()] = 2;
230+
final Map<Object, Object> m6 = HashMap.identity()
231+
..[Thing()] = 1
232+
..[Thing()] = 2;
235233
final Map<Object, Object> m7 = UnmodifiableMapView(m1);
236234
final Map<Object, Object> m8 = UnmodifiableMapView(m2);
237235
final Map<Object, Object> m9 = UnmodifiableMapView(m3);

benchmarks/MemoryCopy/dart/MemoryCopy.dart

+40-43
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,39 @@ import 'package:ffi/ffi.dart';
1313

1414
const maxSizeInBytes = 10 * 1024 * 1024;
1515

16-
final argParser =
17-
ArgParser()
18-
..addMultiOption(
19-
'length',
20-
abbr: 'l',
21-
help: 'Byte length to benchmark',
22-
valueHelp: 'INT',
23-
defaultsTo: const [],
24-
)
25-
..addFlag(
26-
'mebibytes-per-second',
27-
abbr: 'm',
28-
help: 'Show MiB/s',
29-
defaultsTo: false,
30-
)
31-
..addFlag(
32-
'nanoseconds-per-byte',
33-
abbr: 'n',
34-
help: 'Show ns/byte',
35-
defaultsTo: false,
36-
)
37-
..addFlag(
38-
'bytes-per-second',
39-
abbr: 'b',
40-
help: 'Show byte/s',
41-
defaultsTo: true,
42-
)
43-
..addFlag('verbose', abbr: 'v', help: 'Verbose output', defaultsTo: false)
44-
..addFlag(
45-
'aligned',
46-
abbr: 'a',
47-
help: 'Align results on initial numbers',
48-
defaultsTo: false,
49-
);
16+
final argParser = ArgParser()
17+
..addMultiOption(
18+
'length',
19+
abbr: 'l',
20+
help: 'Byte length to benchmark',
21+
valueHelp: 'INT',
22+
defaultsTo: const [],
23+
)
24+
..addFlag(
25+
'mebibytes-per-second',
26+
abbr: 'm',
27+
help: 'Show MiB/s',
28+
defaultsTo: false,
29+
)
30+
..addFlag(
31+
'nanoseconds-per-byte',
32+
abbr: 'n',
33+
help: 'Show ns/byte',
34+
defaultsTo: false,
35+
)
36+
..addFlag(
37+
'bytes-per-second',
38+
abbr: 'b',
39+
help: 'Show byte/s',
40+
defaultsTo: true,
41+
)
42+
..addFlag('verbose', abbr: 'v', help: 'Verbose output', defaultsTo: false)
43+
..addFlag(
44+
'aligned',
45+
abbr: 'a',
46+
help: 'Align results on initial numbers',
47+
defaultsTo: false,
48+
);
5049

5150
class Emitter {
5251
final bool bytesPerSecond;
@@ -118,10 +117,9 @@ abstract class MemoryCopyBenchmark {
118117
// to avoid discarding results that almost, but not quite, reach the minimum
119118
// duration requested.
120119
final allowedJitter = Duration(
121-
microseconds:
122-
minDuration.inSeconds > 0
123-
? (minDuration.inMicroseconds * 0.1).floor()
124-
: 0,
120+
microseconds: minDuration.inSeconds > 0
121+
? (minDuration.inMicroseconds * 0.1).floor()
122+
: 0,
125123
);
126124

127125
final watch = Stopwatch()..start();
@@ -475,11 +473,10 @@ void main(List<String> args) {
475473
List<int> lengthsInBytes = defaultLengthsInBytes;
476474
final emitter = Emitter(results);
477475
if (results['length'].isNotEmpty) {
478-
lengthsInBytes =
479-
(results['length'] as List<String>)
480-
.map(int.parse)
481-
.where((i) => i <= maxSizeInBytes)
482-
.toList();
476+
lengthsInBytes = (results['length'] as List<String>)
477+
.map(int.parse)
478+
.where((i) => i <= maxSizeInBytes)
479+
.toList();
483480
}
484481
final filter = results.rest.firstOrNull;
485482
final benchmarks = [

benchmarks/MultipleReturns/dart/MultipleReturns.dart

+4-8
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,14 @@ ResultClass forwardedClass() => notInlinedClass();
6969
@pragma('vm:prefer-inline')
7070
@pragma('wasm:prefer-inline')
7171
@pragma('dart2js:prefer-inline')
72-
({int result0, String result1}) inlinedRecordNamed() => (
73-
result0: input1,
74-
result1: input2,
75-
);
72+
({int result0, String result1}) inlinedRecordNamed() =>
73+
(result0: input1, result1: input2);
7674

7775
@pragma('vm:never-inline')
7876
@pragma('wasm:never-inline')
7977
@pragma('dart2js:never-inline')
80-
({int result0, String result1}) notInlinedRecordNamed() => (
81-
result0: input1,
82-
result1: input2,
83-
);
78+
({int result0, String result1}) notInlinedRecordNamed() =>
79+
(result0: input1, result1: input2);
8480

8581
@pragma('vm:never-inline')
8682
@pragma('wasm:never-inline')

benchmarks/OmnibusDeferred/dart/OmnibusDeferred.dart

+4-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ final Map<String, Lib> benchmarks = {
5050
'ListCopy': Lib(lib_ListCopy.loadLibrary, () => lib_ListCopy.main()),
5151
'MapCopy': Lib(lib_MapCopy.loadLibrary, () => lib_MapCopy.main([])),
5252
'MD5': Lib(lib_MD5.loadLibrary, () => lib_MD5.main()),
53-
'MultipleReturns':
54-
Lib(lib_MultipleReturns.loadLibrary, () => lib_MultipleReturns.main()),
53+
'MultipleReturns': Lib(
54+
lib_MultipleReturns.loadLibrary,
55+
() => lib_MultipleReturns.main(),
56+
),
5557
'RecordCollections': Lib(
5658
lib_RecordCollections.loadLibrary,
5759
() => lib_RecordCollections.main(),

benchmarks/Startup/dart/Startup.dart

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ Future<void> main(List<String> args) async {
2323
var events;
2424
try {
2525
tempDir = await Directory.systemTemp.createTemp();
26-
final timelinePath =
27-
tempDir.uri.resolve('Startup-timeline.json').toFilePath();
26+
final timelinePath = tempDir.uri
27+
.resolve('Startup-timeline.json')
28+
.toFilePath();
2829
final p = await Process.run(Platform.executable, [
2930
...Platform.executableArguments,
3031
'--timeline_recorder=file:$timelinePath',

0 commit comments

Comments
 (0)