From e4c8b49dcc81546e0138db431fc9e133e2a2a7b8 Mon Sep 17 00:00:00 2001 From: Robert Nystrom Date: Mon, 18 Nov 2024 10:06:01 +0000 Subject: [PATCH] Format benchmarks/. Change-Id: I1362ada67a02b0ed352612fc29c727e94d8cd254 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394901 Commit-Queue: Daco Harkes Auto-Submit: Bob Nystrom Reviewed-by: Daco Harkes --- .../AsyncLiveVars/dart/AsyncLiveVars.dart | 20 +- .../AsyncLiveVars/dart2/AsyncLiveVars.dart | 20 +- .../dart/BigIntParsePrint.dart | 23 +- .../dart/native_version_javascript.dart | 8 +- .../dart2/BigIntParsePrint.dart | 23 +- .../dart2/native_version_javascript.dart | 8 +- benchmarks/Calls/dart/Calls.dart | 139 +- benchmarks/Calls/dart2/Calls.dart | 139 +- benchmarks/Dynamic/dart/Dynamic.dart | 56 +- benchmarks/Dynamic/dart2/Dynamic.dart | 56 +- .../dart/EventLoopLatencyJson.dart | 6 +- .../EventLoopLatencyJson/dart/latency.dart | 38 +- .../dart2/EventLoopLatencyJson.dart | 6 +- .../EventLoopLatencyJson/dart2/latency.dart | 38 +- .../dart/EventLoopLatencyJson350KB.dart | 6 +- .../dart/latency.dart | 38 +- .../dart2/EventLoopLatencyJson350KB.dart | 6 +- .../dart2/latency.dart | 38 +- .../dart/EventLoopLatencyRegexp.dart | 6 +- .../EventLoopLatencyRegexp/dart/latency.dart | 38 +- .../dart2/EventLoopLatencyRegexp.dart | 6 +- .../EventLoopLatencyRegexp/dart2/latency.dart | 38 +- .../FfiAsTypedList/dart/FfiAsTypedList.dart | 4 +- .../FfiBoringssl/dart/FfiBoringssl.dart | 5 +- benchmarks/FfiBoringssl/dart/digest.dart | 56 +- benchmarks/FfiCall/dart/FfiCall.dart | 33 +- .../FfiCall/dart/benchmark_generated.dart | 2668 +++++++++++------ benchmarks/FfiCall/dart/dlopen_helper.dart | 12 +- benchmarks/FfiCall/generate_benchmarks.dart | 83 +- benchmarks/FfiMemory/dart/FfiMemory.dart | 5 +- benchmarks/FfiStruct/dart/FfiStruct.dart | 4 +- benchmarks/FfiStruct/dart2/FfiStruct.dart | 4 +- .../FfiStructCopy/dart/FfiStructCopy.dart | 9 +- .../FfiStructCopy/generate_benchmarks.dart | 7 +- benchmarks/FileIOSink/dart/FileIOSink.dart | 6 +- .../FunctionToJs/dart/FunctionToJs.dart | 155 +- benchmarks/InstantiateTypeArgs/generate.dart | 10 +- .../dart/IntegerSetLookup.dart | 6 +- .../dart2/IntegerSetLookup.dart | 6 +- benchmarks/Isolate/dart/Isolate.dart | 36 +- benchmarks/Isolate/dart2/Isolate.dart | 36 +- .../dart/IsolateBaseOverhead.dart | 26 +- .../dart2/IsolateBaseOverhead.dart | 26 +- benchmarks/IsolateJson/dart/IsolateJson.dart | 55 +- benchmarks/IsolateJson/dart2/IsolateJson.dart | 55 +- .../IsolateRegExp/dart/IsolateRegExp.dart | 14 +- .../dart/IsolateSendExitLatency.dart | 17 +- .../IsolateSendExitLatency/dart/latency.dart | 36 +- .../dart2/IsolateSendExitLatency.dart | 17 +- .../IsolateSendExitLatency/dart2/latency.dart | 36 +- .../IsolateSpawn/dart/IsolateSpawn.dart | 60 +- .../IsolateSpawn/dart2/IsolateSpawn.dart | 62 +- .../dart/IsolateSpawnMemory.dart | 27 +- .../dart2/IsolateSpawnMemory.dart | 27 +- benchmarks/Iterators/dart/Iterators.dart | 130 +- benchmarks/Iterators/dart/data.dart | 12 +- benchmarks/ListCopy/dart/ListCopy.dart | 100 +- benchmarks/ListCopy/dart2/ListCopy.dart | 100 +- .../dart/LongStringCompare.dart | 2 +- benchmarks/MD5/dart/md5.dart | 4 +- benchmarks/MapCopy/dart/MapCopy.dart | 32 +- benchmarks/MapLookup/dart/maps.dart | 8 +- benchmarks/MapLookup/dart2/maps.dart | 8 +- benchmarks/MapLookup/generate_maps.dart | 8 +- benchmarks/MemoryCopy/dart/MemoryCopy.dart | 101 +- .../MultipleReturns/dart/MultipleReturns.dart | 14 +- benchmarks/NativeCall/dart/NativeCall.dart | 186 +- benchmarks/NativeCall/dart2/NativeCall.dart | 186 +- benchmarks/ObjectHash/dart/ObjectHash.dart | 16 +- .../ObjectHashPerf/dart/ObjectHashPerf.dart | 16 +- .../OmnibusDeferred/dart/OmnibusDeferred.dart | 55 +- .../dart2/OmnibusDeferred.dart | 40 +- .../dart/RecordCollections.dart | 79 +- benchmarks/Richards/dart/Richards.dart | 14 +- benchmarks/Richards/dart2/Richards.dart | 12 +- benchmarks/RuntimeType/dart/RuntimeType.dart | 49 +- benchmarks/RuntimeType/dart2/RuntimeType.dart | 49 +- .../dart/SDKArtifactSizes.dart | 14 +- .../dart2/SDKArtifactSizes.dart | 14 +- benchmarks/SHA1/dart/sha1.dart | 4 +- benchmarks/SHA256/dart/sha256.dart | 4 +- benchmarks/SendPort/dart/SendPort.dart | 9 +- benchmarks/SendPort/dart2/SendPort.dart | 9 +- .../dart/SoundSplayTreeSieve.dart | 11 +- .../dart2/SoundSplayTreeSieve.dart | 11 +- benchmarks/Startup/dart/Startup.dart | 7 +- benchmarks/Startup/dart2/Startup.dart | 7 +- benchmarks/StringPool/dart/version1a.dart | 2 +- benchmarks/StringPool/dart/version1b.dart | 2 +- benchmarks/StringPool/dart/version2.dart | 2 +- benchmarks/SubtypeTestCache/generate.dart | 7 +- benchmarks/SwitchFSM/dart/SwitchFSM.dart | 58 +- benchmarks/TypeLiteral/dart/TypeLiteral.dart | 22 +- benchmarks/TypedData/dart/TypedData.dart | 2 +- benchmarks/TypedData/dart2/TypedData.dart | 2 +- .../dart/TypedDataDuplicate.dart | 10 +- .../dart2/TypedDataDuplicate.dart | 10 +- .../TypedDataPoly/dart/TypedDataPoly.dart | 78 +- benchmarks/UiMatrix/dart/UiMatrixHarness.dart | 183 +- benchmarks/UiMatrix/dart/uimatrix.dart | 62 +- benchmarks/Utf8Decode/dart/Utf8Decode.dart | 20 +- benchmarks/Utf8Decode/dart2/Utf8Decode.dart | 20 +- .../Utf8DecodeComplex/dart/benchmarks.dart | 70 +- benchmarks/Utf8Encode/dart/Utf8Encode.dart | 25 +- benchmarks/Utf8Encode/dart2/Utf8Encode.dart | 25 +- .../dart/WasmDataTransfer.dart | 8 +- 106 files changed, 3873 insertions(+), 2405 deletions(-) diff --git a/benchmarks/AsyncLiveVars/dart/AsyncLiveVars.dart b/benchmarks/AsyncLiveVars/dart/AsyncLiveVars.dart index fc28d1be2d8..37fd33d86e6 100644 --- a/benchmarks/AsyncLiveVars/dart/AsyncLiveVars.dart +++ b/benchmarks/AsyncLiveVars/dart/AsyncLiveVars.dart @@ -11,8 +11,10 @@ import 'package:benchmark_harness/benchmark_harness.dart'; class MockClass { static final String str = "${int.parse('42')}"; - static final List list = - List.filled(int.parse('3'), int.parse('42')); + static final List list = List.filled( + int.parse('3'), + int.parse('42'), + ); @pragma('vm:never-inline') @pragma('wasm:never-inline') @@ -43,8 +45,16 @@ class MockClass { @pragma('vm:never-inline') @pragma('wasm:never-inline') @pragma('dart2js:noInline') - void use8(String a0, List a1, String a2, List a3, String a4, - List a5, String a6, List a7) => + void use8( + String a0, + List a1, + String a2, + List a3, + String a4, + List a5, + String a6, + List a7, + ) => a0.length + a1.length + a2.length + @@ -310,7 +320,7 @@ Future main() async { LiveInt1(), LiveInt4(), LiveObj2Int2(), - LiveObj4Int4() + LiveObj4Int4(), ]; for (final bench in benchmarks) { await bench.report(); diff --git a/benchmarks/AsyncLiveVars/dart2/AsyncLiveVars.dart b/benchmarks/AsyncLiveVars/dart2/AsyncLiveVars.dart index 20ac7262a63..f3d829a2b0a 100644 --- a/benchmarks/AsyncLiveVars/dart2/AsyncLiveVars.dart +++ b/benchmarks/AsyncLiveVars/dart2/AsyncLiveVars.dart @@ -13,8 +13,10 @@ import 'package:benchmark_harness/benchmark_harness.dart'; class MockClass { static final String str = "${int.parse('42')}"; - static final List list = - List.filled(int.parse('3'), int.parse('42')); + static final List list = List.filled( + int.parse('3'), + int.parse('42'), + ); @pragma('vm:never-inline') @pragma('dart2js:noInline') @@ -39,8 +41,16 @@ class MockClass { @pragma('vm:never-inline') @pragma('dart2js:noInline') - void use8(String a0, List a1, String a2, List a3, String a4, - List a5, String a6, List a7) => + void use8( + String a0, + List a1, + String a2, + List a3, + String a4, + List a5, + String a6, + List a7, + ) => a0.length + a1.length + a2.length + @@ -299,7 +309,7 @@ Future main() async { LiveInt1(), LiveInt4(), LiveObj2Int2(), - LiveObj4Int4() + LiveObj4Int4(), ]; for (final bench in benchmarks) { await bench.report(); diff --git a/benchmarks/BigIntParsePrint/dart/BigIntParsePrint.dart b/benchmarks/BigIntParsePrint/dart/BigIntParsePrint.dart index a1f4e24e9b1..62baeae447c 100644 --- a/benchmarks/BigIntParsePrint/dart/BigIntParsePrint.dart +++ b/benchmarks/BigIntParsePrint/dart/BigIntParsePrint.dart @@ -31,8 +31,8 @@ const requiredDigits = 11106; class Benchmark extends BenchmarkBase { final List strings; Benchmark(String name, int bits, {bool forInt = false}) - : strings = generateStrings(bits, forInt), - super(name); + : strings = generateStrings(bits, forInt), + super(name); static List generateStrings(int bits, bool forInt) { final List strings = []; @@ -270,7 +270,9 @@ class DummyBenchmark extends BenchmarkBase { /// is not available. This is to satisfy Golem's constraint that group /// benchmarks always produce results for the same set of series. BenchmarkBase Function() selectParseNativeBigIntBenchmark( - String name, int bits) { + String name, + int bits, +) { return nativeBigInt.enabled ? () => ParseJsBigIntBenchmark(name, bits) : () => DummyBenchmark(name); @@ -280,7 +282,9 @@ BenchmarkBase Function() selectParseNativeBigIntBenchmark( /// is not available. This is to satisfy Golem's constraint that group /// benchmarks always produce results for the same set of series. BenchmarkBase Function() selectFormatNativeBigIntBenchmark( - String name, int bits) { + String name, + int bits, +) { return nativeBigInt.enabled ? () => FormatJsBigIntBenchmark(name, bits) : () => DummyBenchmark(name); @@ -330,10 +334,13 @@ void main() { ]; // Warm up all benchmarks to ensure consistent behavior of shared code. - benchmarks.forEach((bm) => bm() - ..setup() - ..run() - ..run()); + benchmarks.forEach( + (bm) => + bm() + ..setup() + ..run() + ..run(), + ); benchmarks.forEach((bm) => bm().report()); } diff --git a/benchmarks/BigIntParsePrint/dart/native_version_javascript.dart b/benchmarks/BigIntParsePrint/dart/native_version_javascript.dart index e8a6bae3373..1819a0f60fb 100644 --- a/benchmarks/BigIntParsePrint/dart/native_version_javascript.dart +++ b/benchmarks/BigIntParsePrint/dart/native_version_javascript.dart @@ -115,9 +115,11 @@ void _setup() { _eval('self.bigint_subtract = function subtract(a, b) { return a - b; }'); _eval('self.bigint_fromInt = function fromInt(i) { return BigInt(i); }'); - _eval('self.bigint_bitLength = function bitLength(b) {' - 'return b == 0 ? 0 : (b < 0 ? ~b : b).toString(2).length;' - '}'); + _eval( + 'self.bigint_bitLength = function bitLength(b) {' + 'return b == 0 ? 0 : (b < 0 ? ~b : b).toString(2).length;' + '}', + ); _eval('self.bigint_isEven = function isEven(b) { return (b & 1n) == 0n; }'); } diff --git a/benchmarks/BigIntParsePrint/dart2/BigIntParsePrint.dart b/benchmarks/BigIntParsePrint/dart2/BigIntParsePrint.dart index a29ce021b71..3edbaac7694 100644 --- a/benchmarks/BigIntParsePrint/dart2/BigIntParsePrint.dart +++ b/benchmarks/BigIntParsePrint/dart2/BigIntParsePrint.dart @@ -38,8 +38,8 @@ const requiredDigits = 11106; class Benchmark extends BenchmarkBase { final List strings; Benchmark(String name, int bits, {bool forInt = false}) - : strings = generateStrings(bits, forInt), - super(name); + : strings = generateStrings(bits, forInt), + super(name); static List generateStrings(int bits, bool forInt) { final List strings = []; @@ -253,7 +253,9 @@ class DummyBenchmark extends BenchmarkBase { /// is not available. This is to satisfy Golem's constraint that group /// benchmarks always produce results for the same set of series. BenchmarkBase Function() selectParseNativeBigIntBenchmark( - String name, int bits) { + String name, + int bits, +) { return nativeBigInt.enabled ? () => ParseJsBigIntBenchmark(name, bits) : () => DummyBenchmark(name); @@ -263,7 +265,9 @@ BenchmarkBase Function() selectParseNativeBigIntBenchmark( /// is not available. This is to satisfy Golem's constraint that group /// benchmarks always produce results for the same set of series. BenchmarkBase Function() selectFormatNativeBigIntBenchmark( - String name, int bits) { + String name, + int bits, +) { return nativeBigInt.enabled ? () => FormatJsBigIntBenchmark(name, bits) : () => DummyBenchmark(name); @@ -313,10 +317,13 @@ void main() { ]; // Warm up all benchmarks to ensure consistent behaviors of shared code. - benchmarks.forEach((bm) => bm() - ..setup() - ..run() - ..run()); + benchmarks.forEach( + (bm) => + bm() + ..setup() + ..run() + ..run(), + ); benchmarks.forEach((bm) => bm().report()); } diff --git a/benchmarks/BigIntParsePrint/dart2/native_version_javascript.dart b/benchmarks/BigIntParsePrint/dart2/native_version_javascript.dart index 37c1eb9b632..dfde2f80981 100644 --- a/benchmarks/BigIntParsePrint/dart2/native_version_javascript.dart +++ b/benchmarks/BigIntParsePrint/dart2/native_version_javascript.dart @@ -117,9 +117,11 @@ void _setup() { _eval('self.bigint_subtract = function subtract(a, b) { return a - b; }'); _eval('self.bigint_fromInt = function fromInt(i) { return BigInt(i); }'); - _eval('self.bigint_bitLength = function bitLength(b) {' - 'return b == 0 ? 0 : (b < 0 ? ~b : b).toString(2).length;' - '}'); + _eval( + 'self.bigint_bitLength = function bitLength(b) {' + 'return b == 0 ? 0 : (b < 0 ? ~b : b).toString(2).length;' + '}', + ); _eval('self.bigint_isEven = function isEven(b) { return (b & 1n) == 0n; }'); } diff --git a/benchmarks/Calls/dart/Calls.dart b/benchmarks/Calls/dart/Calls.dart index 5715a627b6a..b3082baa504 100644 --- a/benchmarks/Calls/dart/Calls.dart +++ b/benchmarks/Calls/dart/Calls.dart @@ -48,65 +48,93 @@ Future main() async { performSyncIterationPolymorphic(generateNumbersManual); performSyncIterationPolymorphic(generateNumbersSyncStarManyYields); - await AsyncCallBenchmark('Calls.AwaitAsyncCall', performAwaitAsyncCalls) - .report(); - await AsyncCallBenchmark('Calls.AwaitAsyncCallClosureTargetPolymorphic', - () => performAwaitCallsClosureTargetPolymorphic(returnAsync)).report(); - await AsyncCallBenchmark('Calls.AwaitAsyncCallInstanceTargetPolymorphic', - () => performAwaitAsyncCallsInstanceTargetPolymorphic(target)).report(); - - await AsyncCallBenchmark('Calls.AwaitFutureCall', performAwaitFutureCalls) - .report(); - await AsyncCallBenchmark('Calls.AwaitFutureCallClosureTargetPolymorphic', - () => performAwaitCallsClosureTargetPolymorphic(returnFuture)).report(); - await AsyncCallBenchmark('Calls.AwaitFutureCallInstanceTargetPolymorphic', - () => performAwaitFutureCallsInstanceTargetPolymorphic(target)).report(); - - await AsyncCallBenchmark('Calls.AwaitFutureOrCall', performAwaitFutureOrCalls) - .report(); - await AsyncCallBenchmark('Calls.AwaitFutureOrCallClosureTargetPolymorphic', - () => performAwaitCallsClosureTargetPolymorphic(returnFutureOr)).report(); - await AsyncCallBenchmark('Calls.AwaitFutureOrCallInstanceTargetPolymorphic', - () => performAwaitFutureOrCallsInstanceTargetPolymorphic(target)) - .report(); await AsyncCallBenchmark( - 'Calls.AwaitFutureOrCallInstanceTargetPolymorphicManyAwaits', - () => - performAwaitAsyncCallsInstanceTargetPolymorphicManyAwaits(target)) - .report(); - - await AsyncCallBenchmark('Calls.AwaitForAsyncStarStreamPolymorphic', - () => performAwaitForIterationPolymorphic(generateNumbersAsyncStar)) - .report(); + 'Calls.AwaitAsyncCall', + performAwaitAsyncCalls, + ).report(); await AsyncCallBenchmark( - 'Calls.AwaitForAsyncStarStreamPolymorphicManyYields', - () => performAwaitForIterationPolymorphic( - generateNumbersAsyncStarManyYields)).report(); - await AsyncCallBenchmark('Calls.AwaitForManualStreamPolymorphic', - () => performAwaitForIterationPolymorphic(generateNumbersManualAsync)) - .report(); + 'Calls.AwaitAsyncCallClosureTargetPolymorphic', + () => performAwaitCallsClosureTargetPolymorphic(returnAsync), + ).report(); + await AsyncCallBenchmark( + 'Calls.AwaitAsyncCallInstanceTargetPolymorphic', + () => performAwaitAsyncCallsInstanceTargetPolymorphic(target), + ).report(); + + await AsyncCallBenchmark( + 'Calls.AwaitFutureCall', + performAwaitFutureCalls, + ).report(); + await AsyncCallBenchmark( + 'Calls.AwaitFutureCallClosureTargetPolymorphic', + () => performAwaitCallsClosureTargetPolymorphic(returnFuture), + ).report(); + await AsyncCallBenchmark( + 'Calls.AwaitFutureCallInstanceTargetPolymorphic', + () => performAwaitFutureCallsInstanceTargetPolymorphic(target), + ).report(); + + await AsyncCallBenchmark( + 'Calls.AwaitFutureOrCall', + performAwaitFutureOrCalls, + ).report(); + await AsyncCallBenchmark( + 'Calls.AwaitFutureOrCallClosureTargetPolymorphic', + () => performAwaitCallsClosureTargetPolymorphic(returnFutureOr), + ).report(); + await AsyncCallBenchmark( + 'Calls.AwaitFutureOrCallInstanceTargetPolymorphic', + () => performAwaitFutureOrCallsInstanceTargetPolymorphic(target), + ).report(); + await AsyncCallBenchmark( + 'Calls.AwaitFutureOrCallInstanceTargetPolymorphicManyAwaits', + () => performAwaitAsyncCallsInstanceTargetPolymorphicManyAwaits(target), + ).report(); + + await AsyncCallBenchmark( + 'Calls.AwaitForAsyncStarStreamPolymorphic', + () => performAwaitForIterationPolymorphic(generateNumbersAsyncStar), + ).report(); + await AsyncCallBenchmark( + 'Calls.AwaitForAsyncStarStreamPolymorphicManyYields', + () => + performAwaitForIterationPolymorphic(generateNumbersAsyncStarManyYields), + ).report(); + await AsyncCallBenchmark( + 'Calls.AwaitForManualStreamPolymorphic', + () => performAwaitForIterationPolymorphic(generateNumbersManualAsync), + ).report(); SyncCallBenchmark('Calls.SyncCall', performSyncCalls).report(); - SyncCallBenchmark('Calls.SyncCallClosureTarget', - () => performSyncCallsClosureTarget(returnSync)).report(); - SyncCallBenchmark('Calls.SyncCallInstanceTargetPolymorphic', - () => performSyncCallsInstanceTargetPolymorphic(target)).report(); - - SyncCallBenchmark('Calls.IterableSyncStarIterablePolymorphic', - () => performSyncIterationPolymorphic(generateNumbersSyncStar)).report(); - SyncCallBenchmark('Calls.IterableManualIterablePolymorphic', - () => performSyncIterationPolymorphic(generateNumbersManual)).report(); SyncCallBenchmark( - 'Calls.IterableManualIterablePolymorphicManyYields', - () => performSyncIterationPolymorphic( - generateNumbersSyncStarManyYields)).report(); + 'Calls.SyncCallClosureTarget', + () => performSyncCallsClosureTarget(returnSync), + ).report(); + SyncCallBenchmark( + 'Calls.SyncCallInstanceTargetPolymorphic', + () => performSyncCallsInstanceTargetPolymorphic(target), + ).report(); + + SyncCallBenchmark( + 'Calls.IterableSyncStarIterablePolymorphic', + () => performSyncIterationPolymorphic(generateNumbersSyncStar), + ).report(); + SyncCallBenchmark( + 'Calls.IterableManualIterablePolymorphic', + () => performSyncIterationPolymorphic(generateNumbersManual), + ).report(); + SyncCallBenchmark( + 'Calls.IterableManualIterablePolymorphicManyYields', + () => performSyncIterationPolymorphic(generateNumbersSyncStarManyYields), + ).report(); } @pragma('vm:never-inline') @pragma('wasm:never-inline') @pragma('dart2js:noInline') Future performAwaitCallsClosureTargetPolymorphic( - FutureOr Function(int) fun) async { + FutureOr Function(int) fun, +) async { int sum = 0; for (int i = 0; i < iterationLimitAsync; ++i) { sum += await fun(i); @@ -119,7 +147,8 @@ Future performAwaitCallsClosureTargetPolymorphic( @pragma('wasm:never-inline') @pragma('dart2js:noInline') Future performAwaitAsyncCallsInstanceTargetPolymorphic( - Target target) async { + Target target, +) async { int sum = 0; for (int i = 0; i < iterationLimitAsync; ++i) { sum += await target.returnAsync(i); @@ -132,7 +161,8 @@ Future performAwaitAsyncCallsInstanceTargetPolymorphic( @pragma('wasm:never-inline') @pragma('dart2js:noInline') Future performAwaitFutureCallsInstanceTargetPolymorphic( - Target target) async { + Target target, +) async { int sum = 0; for (int i = 0; i < iterationLimitAsync; ++i) { sum += await target.returnFuture(i); @@ -145,7 +175,8 @@ Future performAwaitFutureCallsInstanceTargetPolymorphic( @pragma('wasm:never-inline') @pragma('dart2js:noInline') Future performAwaitFutureOrCallsInstanceTargetPolymorphic( - Target target) async { + Target target, +) async { int sum = 0; for (int i = 0; i < iterationLimitAsync; ++i) { sum += await target.returnFutureOr(i); @@ -194,7 +225,8 @@ Future performAwaitFutureOrCalls() async { @pragma('wasm:never-inline') @pragma('dart2js:noInline') Future performAwaitAsyncCallsInstanceTargetPolymorphicManyAwaits( - Target t) async { + Target t, +) async { int sum = 0; int i = 0; @@ -295,7 +327,8 @@ Future performAwaitAsyncCallsInstanceTargetPolymorphicManyAwaits( @pragma('wasm:never-inline') @pragma('dart2js:noInline') Future performAwaitForIterationPolymorphic( - Stream Function(int) fun) async { + Stream Function(int) fun, +) async { int sum = 0; await for (int value in fun(iterationLimitAsync)) { sum += value; diff --git a/benchmarks/Calls/dart2/Calls.dart b/benchmarks/Calls/dart2/Calls.dart index e1d07c9cd09..23e992fba32 100644 --- a/benchmarks/Calls/dart2/Calls.dart +++ b/benchmarks/Calls/dart2/Calls.dart @@ -50,64 +50,92 @@ Future main() async { performSyncIterationPolymorphic(generateNumbersManual); performSyncIterationPolymorphic(generateNumbersSyncStarManyYields); - await AsyncCallBenchmark('Calls.AwaitAsyncCall', performAwaitAsyncCalls) - .report(); - await AsyncCallBenchmark('Calls.AwaitAsyncCallClosureTargetPolymorphic', - () => performAwaitCallsClosureTargetPolymorphic(returnAsync)).report(); - await AsyncCallBenchmark('Calls.AwaitAsyncCallInstanceTargetPolymorphic', - () => performAwaitAsyncCallsInstanceTargetPolymorphic(target)).report(); - - await AsyncCallBenchmark('Calls.AwaitFutureCall', performAwaitFutureCalls) - .report(); - await AsyncCallBenchmark('Calls.AwaitFutureCallClosureTargetPolymorphic', - () => performAwaitCallsClosureTargetPolymorphic(returnFuture)).report(); - await AsyncCallBenchmark('Calls.AwaitFutureCallInstanceTargetPolymorphic', - () => performAwaitFutureCallsInstanceTargetPolymorphic(target)).report(); - - await AsyncCallBenchmark('Calls.AwaitFutureOrCall', performAwaitFutureOrCalls) - .report(); - await AsyncCallBenchmark('Calls.AwaitFutureOrCallClosureTargetPolymorphic', - () => performAwaitCallsClosureTargetPolymorphic(returnFutureOr)).report(); - await AsyncCallBenchmark('Calls.AwaitFutureOrCallInstanceTargetPolymorphic', - () => performAwaitFutureOrCallsInstanceTargetPolymorphic(target)) - .report(); await AsyncCallBenchmark( - 'Calls.AwaitFutureOrCallInstanceTargetPolymorphicManyAwaits', - () => - performAwaitAsyncCallsInstanceTargetPolymorphicManyAwaits(target)) - .report(); - - await AsyncCallBenchmark('Calls.AwaitForAsyncStarStreamPolymorphic', - () => performAwaitForIterationPolymorphic(generateNumbersAsyncStar)) - .report(); + 'Calls.AwaitAsyncCall', + performAwaitAsyncCalls, + ).report(); await AsyncCallBenchmark( - 'Calls.AwaitForAsyncStarStreamPolymorphicManyYields', - () => performAwaitForIterationPolymorphic( - generateNumbersAsyncStarManyYields)).report(); - await AsyncCallBenchmark('Calls.AwaitForManualStreamPolymorphic', - () => performAwaitForIterationPolymorphic(generateNumbersManualAsync)) - .report(); + 'Calls.AwaitAsyncCallClosureTargetPolymorphic', + () => performAwaitCallsClosureTargetPolymorphic(returnAsync), + ).report(); + await AsyncCallBenchmark( + 'Calls.AwaitAsyncCallInstanceTargetPolymorphic', + () => performAwaitAsyncCallsInstanceTargetPolymorphic(target), + ).report(); + + await AsyncCallBenchmark( + 'Calls.AwaitFutureCall', + performAwaitFutureCalls, + ).report(); + await AsyncCallBenchmark( + 'Calls.AwaitFutureCallClosureTargetPolymorphic', + () => performAwaitCallsClosureTargetPolymorphic(returnFuture), + ).report(); + await AsyncCallBenchmark( + 'Calls.AwaitFutureCallInstanceTargetPolymorphic', + () => performAwaitFutureCallsInstanceTargetPolymorphic(target), + ).report(); + + await AsyncCallBenchmark( + 'Calls.AwaitFutureOrCall', + performAwaitFutureOrCalls, + ).report(); + await AsyncCallBenchmark( + 'Calls.AwaitFutureOrCallClosureTargetPolymorphic', + () => performAwaitCallsClosureTargetPolymorphic(returnFutureOr), + ).report(); + await AsyncCallBenchmark( + 'Calls.AwaitFutureOrCallInstanceTargetPolymorphic', + () => performAwaitFutureOrCallsInstanceTargetPolymorphic(target), + ).report(); + await AsyncCallBenchmark( + 'Calls.AwaitFutureOrCallInstanceTargetPolymorphicManyAwaits', + () => performAwaitAsyncCallsInstanceTargetPolymorphicManyAwaits(target), + ).report(); + + await AsyncCallBenchmark( + 'Calls.AwaitForAsyncStarStreamPolymorphic', + () => performAwaitForIterationPolymorphic(generateNumbersAsyncStar), + ).report(); + await AsyncCallBenchmark( + 'Calls.AwaitForAsyncStarStreamPolymorphicManyYields', + () => + performAwaitForIterationPolymorphic(generateNumbersAsyncStarManyYields), + ).report(); + await AsyncCallBenchmark( + 'Calls.AwaitForManualStreamPolymorphic', + () => performAwaitForIterationPolymorphic(generateNumbersManualAsync), + ).report(); SyncCallBenchmark('Calls.SyncCall', performSyncCalls).report(); - SyncCallBenchmark('Calls.SyncCallClosureTarget', - () => performSyncCallsClosureTarget(returnSync)).report(); - SyncCallBenchmark('Calls.SyncCallInstanceTargetPolymorphic', - () => performSyncCallsInstanceTargetPolymorphic(target)).report(); - - SyncCallBenchmark('Calls.IterableSyncStarIterablePolymorphic', - () => performSyncIterationPolymorphic(generateNumbersSyncStar)).report(); - SyncCallBenchmark('Calls.IterableManualIterablePolymorphic', - () => performSyncIterationPolymorphic(generateNumbersManual)).report(); SyncCallBenchmark( - 'Calls.IterableManualIterablePolymorphicManyYields', - () => performSyncIterationPolymorphic( - generateNumbersSyncStarManyYields)).report(); + 'Calls.SyncCallClosureTarget', + () => performSyncCallsClosureTarget(returnSync), + ).report(); + SyncCallBenchmark( + 'Calls.SyncCallInstanceTargetPolymorphic', + () => performSyncCallsInstanceTargetPolymorphic(target), + ).report(); + + SyncCallBenchmark( + 'Calls.IterableSyncStarIterablePolymorphic', + () => performSyncIterationPolymorphic(generateNumbersSyncStar), + ).report(); + SyncCallBenchmark( + 'Calls.IterableManualIterablePolymorphic', + () => performSyncIterationPolymorphic(generateNumbersManual), + ).report(); + SyncCallBenchmark( + 'Calls.IterableManualIterablePolymorphicManyYields', + () => performSyncIterationPolymorphic(generateNumbersSyncStarManyYields), + ).report(); } @pragma('vm:never-inline') @pragma('dart2js:noInline') Future performAwaitCallsClosureTargetPolymorphic( - FutureOr Function(int) fun) async { + FutureOr Function(int) fun, +) async { int sum = 0; for (int i = 0; i < iterationLimitAsync; ++i) { sum += await fun(i); @@ -119,7 +147,8 @@ Future performAwaitCallsClosureTargetPolymorphic( @pragma('vm:never-inline') @pragma('dart2js:noInline') Future performAwaitAsyncCallsInstanceTargetPolymorphic( - Target target) async { + Target target, +) async { int sum = 0; for (int i = 0; i < iterationLimitAsync; ++i) { sum += await target.returnAsync(i); @@ -131,7 +160,8 @@ Future performAwaitAsyncCallsInstanceTargetPolymorphic( @pragma('vm:never-inline') @pragma('dart2js:noInline') Future performAwaitFutureCallsInstanceTargetPolymorphic( - Target target) async { + Target target, +) async { int sum = 0; for (int i = 0; i < iterationLimitAsync; ++i) { sum += await target.returnFuture(i); @@ -143,7 +173,8 @@ Future performAwaitFutureCallsInstanceTargetPolymorphic( @pragma('vm:never-inline') @pragma('dart2js:noInline') Future performAwaitFutureOrCallsInstanceTargetPolymorphic( - Target target) async { + Target target, +) async { int sum = 0; for (int i = 0; i < iterationLimitAsync; ++i) { sum += await target.returnFutureOr(i); @@ -188,7 +219,8 @@ Future performAwaitFutureOrCalls() async { @pragma('vm:never-inline') @pragma('dart2js:noInline') Future performAwaitAsyncCallsInstanceTargetPolymorphicManyAwaits( - Target t) async { + Target t, +) async { int sum = 0; int i = 0; @@ -288,7 +320,8 @@ Future performAwaitAsyncCallsInstanceTargetPolymorphicManyAwaits( @pragma('vm:never-inline') @pragma('dart2js:noInline') Future performAwaitForIterationPolymorphic( - Stream Function(int) fun) async { + Stream Function(int) fun, +) async { int sum = 0; await for (int value in fun(iterationLimitAsync)) { sum += value; diff --git a/benchmarks/Dynamic/dart/Dynamic.dart b/benchmarks/Dynamic/dart/Dynamic.dart index db124796a7c..98ea9c60ec6 100644 --- a/benchmarks/Dynamic/dart/Dynamic.dart +++ b/benchmarks/Dynamic/dart/Dynamic.dart @@ -152,7 +152,7 @@ class NonDynamicClosure extends BenchmarkBase { class NonDynamicFunctionOptSkipped extends BenchmarkBase { const NonDynamicFunctionOptSkipped() - : super('Dynamic.NonDynamicFunctionOptSkipped'); + : super('Dynamic.NonDynamicFunctionOptSkipped'); @override void run() { @@ -164,7 +164,7 @@ class NonDynamicFunctionOptSkipped extends BenchmarkBase { class NonDynamicFunctionOptProvided extends BenchmarkBase { const NonDynamicFunctionOptProvided() - : super('Dynamic.NonDynamicFunctionOptProvided'); + : super('Dynamic.NonDynamicFunctionOptProvided'); @override void run() { @@ -176,7 +176,7 @@ class NonDynamicFunctionOptProvided extends BenchmarkBase { class NonDynamicFunctionNamedSkipped extends BenchmarkBase { const NonDynamicFunctionNamedSkipped() - : super('Dynamic.NonDynamicFunctionNamedSkipped'); + : super('Dynamic.NonDynamicFunctionNamedSkipped'); @override void run() { @@ -188,7 +188,7 @@ class NonDynamicFunctionNamedSkipped extends BenchmarkBase { class NonDynamicFunctionNamedProvided extends BenchmarkBase { const NonDynamicFunctionNamedProvided() - : super('Dynamic.NonDynamicFunctionNamedProvided'); + : super('Dynamic.NonDynamicFunctionNamedProvided'); @override void run() { @@ -200,7 +200,7 @@ class NonDynamicFunctionNamedProvided extends BenchmarkBase { class NonDynamicClosureOptSkipped extends BenchmarkBase { const NonDynamicClosureOptSkipped() - : super('Dynamic.NonDynamicClosureOptSkipped'); + : super('Dynamic.NonDynamicClosureOptSkipped'); @override void run() { @@ -212,7 +212,7 @@ class NonDynamicClosureOptSkipped extends BenchmarkBase { class NonDynamicClosureOptProvided extends BenchmarkBase { const NonDynamicClosureOptProvided() - : super('Dynamic.NonDynamicClosureOptProvided'); + : super('Dynamic.NonDynamicClosureOptProvided'); @override void run() { @@ -224,7 +224,7 @@ class NonDynamicClosureOptProvided extends BenchmarkBase { class NonDynamicClosureNamedSkipped extends BenchmarkBase { const NonDynamicClosureNamedSkipped() - : super('Dynamic.NonDynamicClosureNamedSkipped'); + : super('Dynamic.NonDynamicClosureNamedSkipped'); @override void run() { @@ -236,7 +236,7 @@ class NonDynamicClosureNamedSkipped extends BenchmarkBase { class NonDynamicClosureNamedProvided extends BenchmarkBase { const NonDynamicClosureNamedProvided() - : super('Dynamic.NonDynamicClosureNamedProvided'); + : super('Dynamic.NonDynamicClosureNamedProvided'); @override void run() { @@ -270,7 +270,7 @@ class DynamicCastClosure extends BenchmarkBase { class DynamicCastFunctionOptSkipped extends BenchmarkBase { const DynamicCastFunctionOptSkipped() - : super('Dynamic.DynamicCastFunctionOptSkipped'); + : super('Dynamic.DynamicCastFunctionOptSkipped'); @override void run() { @@ -282,7 +282,7 @@ class DynamicCastFunctionOptSkipped extends BenchmarkBase { class DynamicCastFunctionOptProvided extends BenchmarkBase { const DynamicCastFunctionOptProvided() - : super('Dynamic.DynamicCastFunctionOptProvided'); + : super('Dynamic.DynamicCastFunctionOptProvided'); @override void run() { @@ -294,7 +294,7 @@ class DynamicCastFunctionOptProvided extends BenchmarkBase { class DynamicCastFunctionNamedSkipped extends BenchmarkBase { const DynamicCastFunctionNamedSkipped() - : super('Dynamic.DynamicCastFunctionNamedSkipped'); + : super('Dynamic.DynamicCastFunctionNamedSkipped'); @override void run() { @@ -306,7 +306,7 @@ class DynamicCastFunctionNamedSkipped extends BenchmarkBase { class DynamicCastFunctionNamedProvided extends BenchmarkBase { const DynamicCastFunctionNamedProvided() - : super('Dynamic.DynamicCastFunctionNamedProvided'); + : super('Dynamic.DynamicCastFunctionNamedProvided'); @override void run() { @@ -318,7 +318,7 @@ class DynamicCastFunctionNamedProvided extends BenchmarkBase { class DynamicCastClosureOptSkipped extends BenchmarkBase { const DynamicCastClosureOptSkipped() - : super('Dynamic.DynamicCastClosureOptSkipped'); + : super('Dynamic.DynamicCastClosureOptSkipped'); @override void run() { @@ -330,7 +330,7 @@ class DynamicCastClosureOptSkipped extends BenchmarkBase { class DynamicCastClosureOptProvided extends BenchmarkBase { const DynamicCastClosureOptProvided() - : super('Dynamic.DynamicCastClosureOptProvided'); + : super('Dynamic.DynamicCastClosureOptProvided'); @override void run() { @@ -342,7 +342,7 @@ class DynamicCastClosureOptProvided extends BenchmarkBase { class DynamicCastClosureNamedSkipped extends BenchmarkBase { const DynamicCastClosureNamedSkipped() - : super('Dynamic.DynamicCastClosureNamedSkipped'); + : super('Dynamic.DynamicCastClosureNamedSkipped'); @override void run() { @@ -354,7 +354,7 @@ class DynamicCastClosureNamedSkipped extends BenchmarkBase { class DynamicCastClosureNamedProvided extends BenchmarkBase { const DynamicCastClosureNamedProvided() - : super('Dynamic.DynamicCastClosureNamedProvided'); + : super('Dynamic.DynamicCastClosureNamedProvided'); @override void run() { @@ -388,7 +388,7 @@ class DynamicDefClosure extends BenchmarkBase { class DynamicDefFunctionOptSkipped extends BenchmarkBase { const DynamicDefFunctionOptSkipped() - : super('Dynamic.DynamicDefFunctionOptSkipped'); + : super('Dynamic.DynamicDefFunctionOptSkipped'); @override void run() { @@ -400,7 +400,7 @@ class DynamicDefFunctionOptSkipped extends BenchmarkBase { class DynamicDefFunctionOptProvided extends BenchmarkBase { const DynamicDefFunctionOptProvided() - : super('Dynamic.DynamicDefFunctionOptProvided'); + : super('Dynamic.DynamicDefFunctionOptProvided'); @override void run() { @@ -412,7 +412,7 @@ class DynamicDefFunctionOptProvided extends BenchmarkBase { class DynamicDefFunctionNamedSkipped extends BenchmarkBase { const DynamicDefFunctionNamedSkipped() - : super('Dynamic.DynamicDefFunctionNamedSkipped'); + : super('Dynamic.DynamicDefFunctionNamedSkipped'); @override void run() { @@ -424,7 +424,7 @@ class DynamicDefFunctionNamedSkipped extends BenchmarkBase { class DynamicDefFunctionNamedProvided extends BenchmarkBase { const DynamicDefFunctionNamedProvided() - : super('Dynamic.DynamicDefFunctionNamedProvided'); + : super('Dynamic.DynamicDefFunctionNamedProvided'); @override void run() { @@ -436,7 +436,7 @@ class DynamicDefFunctionNamedProvided extends BenchmarkBase { class DynamicDefClosureOptSkipped extends BenchmarkBase { const DynamicDefClosureOptSkipped() - : super('Dynamic.DynamicDefClosureOptSkipped'); + : super('Dynamic.DynamicDefClosureOptSkipped'); @override void run() { @@ -448,7 +448,7 @@ class DynamicDefClosureOptSkipped extends BenchmarkBase { class DynamicDefClosureOptProvided extends BenchmarkBase { const DynamicDefClosureOptProvided() - : super('Dynamic.DynamicDefClosureOptProvided'); + : super('Dynamic.DynamicDefClosureOptProvided'); @override void run() { @@ -460,7 +460,7 @@ class DynamicDefClosureOptProvided extends BenchmarkBase { class DynamicDefClosureNamedSkipped extends BenchmarkBase { const DynamicDefClosureNamedSkipped() - : super('Dynamic.DynamicDefClosureNamedSkipped'); + : super('Dynamic.DynamicDefClosureNamedSkipped'); @override void run() { @@ -472,7 +472,7 @@ class DynamicDefClosureNamedSkipped extends BenchmarkBase { class DynamicDefClosureNamedProvided extends BenchmarkBase { const DynamicDefClosureNamedProvided() - : super('Dynamic.DynamicDefClosureNamedProvided'); + : super('Dynamic.DynamicDefClosureNamedProvided'); @override void run() { @@ -485,8 +485,8 @@ class DynamicDefClosureNamedProvided extends BenchmarkBase { class DynamicClassASingleton extends BenchmarkBase { final A a; const DynamicClassASingleton() - : a = const A(), - super('Dynamic.DynamicClassASingleton'); + : a = const A(), + super('Dynamic.DynamicClassASingleton'); @override void run() { @@ -499,8 +499,8 @@ class DynamicClassASingleton extends BenchmarkBase { class DynamicClassBSingleton extends BenchmarkBase { final B b; const DynamicClassBSingleton() - : b = const B(), - super('Dynamic.DynamicClassBSingleton'); + : b = const B(), + super('Dynamic.DynamicClassBSingleton'); @override void run() { diff --git a/benchmarks/Dynamic/dart2/Dynamic.dart b/benchmarks/Dynamic/dart2/Dynamic.dart index c91658d91c1..1da925606d3 100644 --- a/benchmarks/Dynamic/dart2/Dynamic.dart +++ b/benchmarks/Dynamic/dart2/Dynamic.dart @@ -134,7 +134,7 @@ class NonDynamicClosure extends BenchmarkBase { class NonDynamicFunctionOptSkipped extends BenchmarkBase { const NonDynamicFunctionOptSkipped() - : super('Dynamic.NonDynamicFunctionOptSkipped'); + : super('Dynamic.NonDynamicFunctionOptSkipped'); @override void run() { @@ -146,7 +146,7 @@ class NonDynamicFunctionOptSkipped extends BenchmarkBase { class NonDynamicFunctionOptProvided extends BenchmarkBase { const NonDynamicFunctionOptProvided() - : super('Dynamic.NonDynamicFunctionOptProvided'); + : super('Dynamic.NonDynamicFunctionOptProvided'); @override void run() { @@ -158,7 +158,7 @@ class NonDynamicFunctionOptProvided extends BenchmarkBase { class NonDynamicFunctionNamedSkipped extends BenchmarkBase { const NonDynamicFunctionNamedSkipped() - : super('Dynamic.NonDynamicFunctionNamedSkipped'); + : super('Dynamic.NonDynamicFunctionNamedSkipped'); @override void run() { @@ -170,7 +170,7 @@ class NonDynamicFunctionNamedSkipped extends BenchmarkBase { class NonDynamicFunctionNamedProvided extends BenchmarkBase { const NonDynamicFunctionNamedProvided() - : super('Dynamic.NonDynamicFunctionNamedProvided'); + : super('Dynamic.NonDynamicFunctionNamedProvided'); @override void run() { @@ -182,7 +182,7 @@ class NonDynamicFunctionNamedProvided extends BenchmarkBase { class NonDynamicClosureOptSkipped extends BenchmarkBase { const NonDynamicClosureOptSkipped() - : super('Dynamic.NonDynamicClosureOptSkipped'); + : super('Dynamic.NonDynamicClosureOptSkipped'); @override void run() { @@ -194,7 +194,7 @@ class NonDynamicClosureOptSkipped extends BenchmarkBase { class NonDynamicClosureOptProvided extends BenchmarkBase { const NonDynamicClosureOptProvided() - : super('Dynamic.NonDynamicClosureOptProvided'); + : super('Dynamic.NonDynamicClosureOptProvided'); @override void run() { @@ -206,7 +206,7 @@ class NonDynamicClosureOptProvided extends BenchmarkBase { class NonDynamicClosureNamedSkipped extends BenchmarkBase { const NonDynamicClosureNamedSkipped() - : super('Dynamic.NonDynamicClosureNamedSkipped'); + : super('Dynamic.NonDynamicClosureNamedSkipped'); @override void run() { @@ -218,7 +218,7 @@ class NonDynamicClosureNamedSkipped extends BenchmarkBase { class NonDynamicClosureNamedProvided extends BenchmarkBase { const NonDynamicClosureNamedProvided() - : super('Dynamic.NonDynamicClosureNamedProvided'); + : super('Dynamic.NonDynamicClosureNamedProvided'); @override void run() { @@ -252,7 +252,7 @@ class DynamicCastClosure extends BenchmarkBase { class DynamicCastFunctionOptSkipped extends BenchmarkBase { const DynamicCastFunctionOptSkipped() - : super('Dynamic.DynamicCastFunctionOptSkipped'); + : super('Dynamic.DynamicCastFunctionOptSkipped'); @override void run() { @@ -264,7 +264,7 @@ class DynamicCastFunctionOptSkipped extends BenchmarkBase { class DynamicCastFunctionOptProvided extends BenchmarkBase { const DynamicCastFunctionOptProvided() - : super('Dynamic.DynamicCastFunctionOptProvided'); + : super('Dynamic.DynamicCastFunctionOptProvided'); @override void run() { @@ -276,7 +276,7 @@ class DynamicCastFunctionOptProvided extends BenchmarkBase { class DynamicCastFunctionNamedSkipped extends BenchmarkBase { const DynamicCastFunctionNamedSkipped() - : super('Dynamic.DynamicCastFunctionNamedSkipped'); + : super('Dynamic.DynamicCastFunctionNamedSkipped'); @override void run() { @@ -288,7 +288,7 @@ class DynamicCastFunctionNamedSkipped extends BenchmarkBase { class DynamicCastFunctionNamedProvided extends BenchmarkBase { const DynamicCastFunctionNamedProvided() - : super('Dynamic.DynamicCastFunctionNamedProvided'); + : super('Dynamic.DynamicCastFunctionNamedProvided'); @override void run() { @@ -300,7 +300,7 @@ class DynamicCastFunctionNamedProvided extends BenchmarkBase { class DynamicCastClosureOptSkipped extends BenchmarkBase { const DynamicCastClosureOptSkipped() - : super('Dynamic.DynamicCastClosureOptSkipped'); + : super('Dynamic.DynamicCastClosureOptSkipped'); @override void run() { @@ -312,7 +312,7 @@ class DynamicCastClosureOptSkipped extends BenchmarkBase { class DynamicCastClosureOptProvided extends BenchmarkBase { const DynamicCastClosureOptProvided() - : super('Dynamic.DynamicCastClosureOptProvided'); + : super('Dynamic.DynamicCastClosureOptProvided'); @override void run() { @@ -324,7 +324,7 @@ class DynamicCastClosureOptProvided extends BenchmarkBase { class DynamicCastClosureNamedSkipped extends BenchmarkBase { const DynamicCastClosureNamedSkipped() - : super('Dynamic.DynamicCastClosureNamedSkipped'); + : super('Dynamic.DynamicCastClosureNamedSkipped'); @override void run() { @@ -336,7 +336,7 @@ class DynamicCastClosureNamedSkipped extends BenchmarkBase { class DynamicCastClosureNamedProvided extends BenchmarkBase { const DynamicCastClosureNamedProvided() - : super('Dynamic.DynamicCastClosureNamedProvided'); + : super('Dynamic.DynamicCastClosureNamedProvided'); @override void run() { @@ -370,7 +370,7 @@ class DynamicDefClosure extends BenchmarkBase { class DynamicDefFunctionOptSkipped extends BenchmarkBase { const DynamicDefFunctionOptSkipped() - : super('Dynamic.DynamicDefFunctionOptSkipped'); + : super('Dynamic.DynamicDefFunctionOptSkipped'); @override void run() { @@ -382,7 +382,7 @@ class DynamicDefFunctionOptSkipped extends BenchmarkBase { class DynamicDefFunctionOptProvided extends BenchmarkBase { const DynamicDefFunctionOptProvided() - : super('Dynamic.DynamicDefFunctionOptProvided'); + : super('Dynamic.DynamicDefFunctionOptProvided'); @override void run() { @@ -394,7 +394,7 @@ class DynamicDefFunctionOptProvided extends BenchmarkBase { class DynamicDefFunctionNamedSkipped extends BenchmarkBase { const DynamicDefFunctionNamedSkipped() - : super('Dynamic.DynamicDefFunctionNamedSkipped'); + : super('Dynamic.DynamicDefFunctionNamedSkipped'); @override void run() { @@ -406,7 +406,7 @@ class DynamicDefFunctionNamedSkipped extends BenchmarkBase { class DynamicDefFunctionNamedProvided extends BenchmarkBase { const DynamicDefFunctionNamedProvided() - : super('Dynamic.DynamicDefFunctionNamedProvided'); + : super('Dynamic.DynamicDefFunctionNamedProvided'); @override void run() { @@ -418,7 +418,7 @@ class DynamicDefFunctionNamedProvided extends BenchmarkBase { class DynamicDefClosureOptSkipped extends BenchmarkBase { const DynamicDefClosureOptSkipped() - : super('Dynamic.DynamicDefClosureOptSkipped'); + : super('Dynamic.DynamicDefClosureOptSkipped'); @override void run() { @@ -430,7 +430,7 @@ class DynamicDefClosureOptSkipped extends BenchmarkBase { class DynamicDefClosureOptProvided extends BenchmarkBase { const DynamicDefClosureOptProvided() - : super('Dynamic.DynamicDefClosureOptProvided'); + : super('Dynamic.DynamicDefClosureOptProvided'); @override void run() { @@ -442,7 +442,7 @@ class DynamicDefClosureOptProvided extends BenchmarkBase { class DynamicDefClosureNamedSkipped extends BenchmarkBase { const DynamicDefClosureNamedSkipped() - : super('Dynamic.DynamicDefClosureNamedSkipped'); + : super('Dynamic.DynamicDefClosureNamedSkipped'); @override void run() { @@ -454,7 +454,7 @@ class DynamicDefClosureNamedSkipped extends BenchmarkBase { class DynamicDefClosureNamedProvided extends BenchmarkBase { const DynamicDefClosureNamedProvided() - : super('Dynamic.DynamicDefClosureNamedProvided'); + : super('Dynamic.DynamicDefClosureNamedProvided'); @override void run() { @@ -467,8 +467,8 @@ class DynamicDefClosureNamedProvided extends BenchmarkBase { class DynamicClassASingleton extends BenchmarkBase { final A a; const DynamicClassASingleton() - : a = const A(), - super('Dynamic.DynamicClassASingleton'); + : a = const A(), + super('Dynamic.DynamicClassASingleton'); @override void run() { @@ -481,8 +481,8 @@ class DynamicClassASingleton extends BenchmarkBase { class DynamicClassBSingleton extends BenchmarkBase { final B b; const DynamicClassBSingleton() - : b = const B(), - super('Dynamic.DynamicClassBSingleton'); + : b = const B(), + super('Dynamic.DynamicClassBSingleton'); @override void run() { diff --git a/benchmarks/EventLoopLatencyJson/dart/EventLoopLatencyJson.dart b/benchmarks/EventLoopLatencyJson/dart/EventLoopLatencyJson.dart index 2cf71a3dac4..1923165d45c 100644 --- a/benchmarks/EventLoopLatencyJson/dart/EventLoopLatencyJson.dart +++ b/benchmarks/EventLoopLatencyJson/dart/EventLoopLatencyJson.dart @@ -16,8 +16,10 @@ Future main() async { // Measure event loop latency. const tickDuration = Duration(milliseconds: 1); const numberOfTicks = 8 * 1000; // min 8 seconds. - final EventLoopLatencyStats stats = - await measureEventLoopLatency(tickDuration, numberOfTicks); + final EventLoopLatencyStats stats = await measureEventLoopLatency( + tickDuration, + numberOfTicks, + ); // Kill isolate & wait until it's dead. isolate.kill(priority: Isolate.immediate); diff --git a/benchmarks/EventLoopLatencyJson/dart/latency.dart b/benchmarks/EventLoopLatencyJson/dart/latency.dart index 5da9f4ee30b..758f4d3091d 100644 --- a/benchmarks/EventLoopLatencyJson/dart/latency.dart +++ b/benchmarks/EventLoopLatencyJson/dart/latency.dart @@ -14,7 +14,9 @@ import 'dart:typed_data'; /// /// Runs [numberOfTicks] times before completing with [EventLoopLatencyStats]. Future measureEventLoopLatency( - Duration tickDuration, int numberOfTicks) { + Duration tickDuration, + int numberOfTicks, +) { final completer = Completer(); final tickDurationInUs = tickDuration.inMicroseconds; @@ -73,14 +75,15 @@ class EventLoopLatencyStats { final int maxRss; EventLoopLatencyStats( - this.minLatency, - this.avgLatency, - this.maxLatency, - this.percentile50th, - this.percentile90th, - this.percentile95th, - this.percentile99th, - this.maxRss); + this.minLatency, + this.avgLatency, + this.maxLatency, + this.percentile50th, + this.percentile90th, + this.percentile95th, + this.percentile99th, + this.maxRss, + ); void report(String name) { print('$name.Min(RunTimeRaw): $minLatency ms.'); @@ -123,13 +126,14 @@ class _TickLatencies { final percentile99th = _timestamps[99 * length ~/ 100]; return EventLoopLatencyStats( - min / 1000, - avg / 1000, - max / 1000, - percentile50th / 1000, - percentile90th / 1000, - percentile95th / 1000, - percentile99th / 1000, - ProcessInfo.maxRss); + min / 1000, + avg / 1000, + max / 1000, + percentile50th / 1000, + percentile90th / 1000, + percentile95th / 1000, + percentile99th / 1000, + ProcessInfo.maxRss, + ); } } diff --git a/benchmarks/EventLoopLatencyJson/dart2/EventLoopLatencyJson.dart b/benchmarks/EventLoopLatencyJson/dart2/EventLoopLatencyJson.dart index 7f2368d2d33..1b9d5e7fa9d 100644 --- a/benchmarks/EventLoopLatencyJson/dart2/EventLoopLatencyJson.dart +++ b/benchmarks/EventLoopLatencyJson/dart2/EventLoopLatencyJson.dart @@ -18,8 +18,10 @@ Future main() async { // Measure event loop latency. const tickDuration = Duration(milliseconds: 1); const numberOfTicks = 8 * 1000; // min 8 seconds. - final EventLoopLatencyStats stats = - await measureEventLoopLatency(tickDuration, numberOfTicks); + final EventLoopLatencyStats stats = await measureEventLoopLatency( + tickDuration, + numberOfTicks, + ); // Kill isolate & wait until it's dead. isolate.kill(priority: Isolate.immediate); diff --git a/benchmarks/EventLoopLatencyJson/dart2/latency.dart b/benchmarks/EventLoopLatencyJson/dart2/latency.dart index 44ecae6001f..de43d974f79 100644 --- a/benchmarks/EventLoopLatencyJson/dart2/latency.dart +++ b/benchmarks/EventLoopLatencyJson/dart2/latency.dart @@ -16,7 +16,9 @@ import 'dart:typed_data'; /// /// Runs [numberOfTicks] times before completing with [EventLoopLatencyStats]. Future measureEventLoopLatency( - Duration tickDuration, int numberOfTicks) { + Duration tickDuration, + int numberOfTicks, +) { final completer = Completer(); final tickDurationInUs = tickDuration.inMicroseconds; @@ -75,14 +77,15 @@ class EventLoopLatencyStats { final int maxRss; EventLoopLatencyStats( - this.minLatency, - this.avgLatency, - this.maxLatency, - this.percentile50th, - this.percentile90th, - this.percentile95th, - this.percentile99th, - this.maxRss); + this.minLatency, + this.avgLatency, + this.maxLatency, + this.percentile50th, + this.percentile90th, + this.percentile95th, + this.percentile99th, + this.maxRss, + ); void report(String name) { print('$name.Min(RunTimeRaw): $minLatency ms.'); @@ -125,13 +128,14 @@ class _TickLatencies { final percentile99th = _timestamps[99 * length ~/ 100]; return EventLoopLatencyStats( - min / 1000, - avg / 1000, - max / 1000, - percentile50th / 1000, - percentile90th / 1000, - percentile95th / 1000, - percentile99th / 1000, - ProcessInfo.maxRss); + min / 1000, + avg / 1000, + max / 1000, + percentile50th / 1000, + percentile90th / 1000, + percentile95th / 1000, + percentile99th / 1000, + ProcessInfo.maxRss, + ); } } diff --git a/benchmarks/EventLoopLatencyJson350KB/dart/EventLoopLatencyJson350KB.dart b/benchmarks/EventLoopLatencyJson350KB/dart/EventLoopLatencyJson350KB.dart index 517de916523..36c781d658c 100644 --- a/benchmarks/EventLoopLatencyJson350KB/dart/EventLoopLatencyJson350KB.dart +++ b/benchmarks/EventLoopLatencyJson350KB/dart/EventLoopLatencyJson350KB.dart @@ -16,8 +16,10 @@ Future main() async { // Measure event loop latency. const tickDuration = Duration(milliseconds: 1); const numberOfTicks = 8 * 1000; // min 8 seconds. - final EventLoopLatencyStats stats = - await measureEventLoopLatency(tickDuration, numberOfTicks); + final EventLoopLatencyStats stats = await measureEventLoopLatency( + tickDuration, + numberOfTicks, + ); // Kill isolate & wait until it's dead. isolate.kill(priority: Isolate.immediate); diff --git a/benchmarks/EventLoopLatencyJson350KB/dart/latency.dart b/benchmarks/EventLoopLatencyJson350KB/dart/latency.dart index 5da9f4ee30b..758f4d3091d 100644 --- a/benchmarks/EventLoopLatencyJson350KB/dart/latency.dart +++ b/benchmarks/EventLoopLatencyJson350KB/dart/latency.dart @@ -14,7 +14,9 @@ import 'dart:typed_data'; /// /// Runs [numberOfTicks] times before completing with [EventLoopLatencyStats]. Future measureEventLoopLatency( - Duration tickDuration, int numberOfTicks) { + Duration tickDuration, + int numberOfTicks, +) { final completer = Completer(); final tickDurationInUs = tickDuration.inMicroseconds; @@ -73,14 +75,15 @@ class EventLoopLatencyStats { final int maxRss; EventLoopLatencyStats( - this.minLatency, - this.avgLatency, - this.maxLatency, - this.percentile50th, - this.percentile90th, - this.percentile95th, - this.percentile99th, - this.maxRss); + this.minLatency, + this.avgLatency, + this.maxLatency, + this.percentile50th, + this.percentile90th, + this.percentile95th, + this.percentile99th, + this.maxRss, + ); void report(String name) { print('$name.Min(RunTimeRaw): $minLatency ms.'); @@ -123,13 +126,14 @@ class _TickLatencies { final percentile99th = _timestamps[99 * length ~/ 100]; return EventLoopLatencyStats( - min / 1000, - avg / 1000, - max / 1000, - percentile50th / 1000, - percentile90th / 1000, - percentile95th / 1000, - percentile99th / 1000, - ProcessInfo.maxRss); + min / 1000, + avg / 1000, + max / 1000, + percentile50th / 1000, + percentile90th / 1000, + percentile95th / 1000, + percentile99th / 1000, + ProcessInfo.maxRss, + ); } } diff --git a/benchmarks/EventLoopLatencyJson350KB/dart2/EventLoopLatencyJson350KB.dart b/benchmarks/EventLoopLatencyJson350KB/dart2/EventLoopLatencyJson350KB.dart index 64e67219aa8..9c0a37355ce 100644 --- a/benchmarks/EventLoopLatencyJson350KB/dart2/EventLoopLatencyJson350KB.dart +++ b/benchmarks/EventLoopLatencyJson350KB/dart2/EventLoopLatencyJson350KB.dart @@ -18,8 +18,10 @@ main() async { // Measure event loop latency. const tickDuration = const Duration(milliseconds: 1); const numberOfTicks = 8 * 1000; // min 8 seconds. - final EventLoopLatencyStats stats = - await measureEventLoopLatency(tickDuration, numberOfTicks); + final EventLoopLatencyStats stats = await measureEventLoopLatency( + tickDuration, + numberOfTicks, + ); // Kill isolate & wait until it's dead. isolate.kill(priority: Isolate.immediate); diff --git a/benchmarks/EventLoopLatencyJson350KB/dart2/latency.dart b/benchmarks/EventLoopLatencyJson350KB/dart2/latency.dart index 44ecae6001f..de43d974f79 100644 --- a/benchmarks/EventLoopLatencyJson350KB/dart2/latency.dart +++ b/benchmarks/EventLoopLatencyJson350KB/dart2/latency.dart @@ -16,7 +16,9 @@ import 'dart:typed_data'; /// /// Runs [numberOfTicks] times before completing with [EventLoopLatencyStats]. Future measureEventLoopLatency( - Duration tickDuration, int numberOfTicks) { + Duration tickDuration, + int numberOfTicks, +) { final completer = Completer(); final tickDurationInUs = tickDuration.inMicroseconds; @@ -75,14 +77,15 @@ class EventLoopLatencyStats { final int maxRss; EventLoopLatencyStats( - this.minLatency, - this.avgLatency, - this.maxLatency, - this.percentile50th, - this.percentile90th, - this.percentile95th, - this.percentile99th, - this.maxRss); + this.minLatency, + this.avgLatency, + this.maxLatency, + this.percentile50th, + this.percentile90th, + this.percentile95th, + this.percentile99th, + this.maxRss, + ); void report(String name) { print('$name.Min(RunTimeRaw): $minLatency ms.'); @@ -125,13 +128,14 @@ class _TickLatencies { final percentile99th = _timestamps[99 * length ~/ 100]; return EventLoopLatencyStats( - min / 1000, - avg / 1000, - max / 1000, - percentile50th / 1000, - percentile90th / 1000, - percentile95th / 1000, - percentile99th / 1000, - ProcessInfo.maxRss); + min / 1000, + avg / 1000, + max / 1000, + percentile50th / 1000, + percentile90th / 1000, + percentile95th / 1000, + percentile99th / 1000, + ProcessInfo.maxRss, + ); } } diff --git a/benchmarks/EventLoopLatencyRegexp/dart/EventLoopLatencyRegexp.dart b/benchmarks/EventLoopLatencyRegexp/dart/EventLoopLatencyRegexp.dart index 554599e547d..95f21f2c5cc 100644 --- a/benchmarks/EventLoopLatencyRegexp/dart/EventLoopLatencyRegexp.dart +++ b/benchmarks/EventLoopLatencyRegexp/dart/EventLoopLatencyRegexp.dart @@ -15,8 +15,10 @@ Future main() async { // Measure event loop latency. const tickDuration = Duration(milliseconds: 1); const numberOfTicks = 8 * 1000; // min 8 seconds. - final EventLoopLatencyStats stats = - await measureEventLoopLatency(tickDuration, numberOfTicks); + final EventLoopLatencyStats stats = await measureEventLoopLatency( + tickDuration, + numberOfTicks, + ); // Kill isolate & wait until it's dead. isolate.kill(priority: Isolate.immediate); diff --git a/benchmarks/EventLoopLatencyRegexp/dart/latency.dart b/benchmarks/EventLoopLatencyRegexp/dart/latency.dart index 5da9f4ee30b..758f4d3091d 100644 --- a/benchmarks/EventLoopLatencyRegexp/dart/latency.dart +++ b/benchmarks/EventLoopLatencyRegexp/dart/latency.dart @@ -14,7 +14,9 @@ import 'dart:typed_data'; /// /// Runs [numberOfTicks] times before completing with [EventLoopLatencyStats]. Future measureEventLoopLatency( - Duration tickDuration, int numberOfTicks) { + Duration tickDuration, + int numberOfTicks, +) { final completer = Completer(); final tickDurationInUs = tickDuration.inMicroseconds; @@ -73,14 +75,15 @@ class EventLoopLatencyStats { final int maxRss; EventLoopLatencyStats( - this.minLatency, - this.avgLatency, - this.maxLatency, - this.percentile50th, - this.percentile90th, - this.percentile95th, - this.percentile99th, - this.maxRss); + this.minLatency, + this.avgLatency, + this.maxLatency, + this.percentile50th, + this.percentile90th, + this.percentile95th, + this.percentile99th, + this.maxRss, + ); void report(String name) { print('$name.Min(RunTimeRaw): $minLatency ms.'); @@ -123,13 +126,14 @@ class _TickLatencies { final percentile99th = _timestamps[99 * length ~/ 100]; return EventLoopLatencyStats( - min / 1000, - avg / 1000, - max / 1000, - percentile50th / 1000, - percentile90th / 1000, - percentile95th / 1000, - percentile99th / 1000, - ProcessInfo.maxRss); + min / 1000, + avg / 1000, + max / 1000, + percentile50th / 1000, + percentile90th / 1000, + percentile95th / 1000, + percentile99th / 1000, + ProcessInfo.maxRss, + ); } } diff --git a/benchmarks/EventLoopLatencyRegexp/dart2/EventLoopLatencyRegexp.dart b/benchmarks/EventLoopLatencyRegexp/dart2/EventLoopLatencyRegexp.dart index 11940c458e3..435c8b7f307 100644 --- a/benchmarks/EventLoopLatencyRegexp/dart2/EventLoopLatencyRegexp.dart +++ b/benchmarks/EventLoopLatencyRegexp/dart2/EventLoopLatencyRegexp.dart @@ -17,8 +17,10 @@ main() async { // Measure event loop latency. const tickDuration = const Duration(milliseconds: 1); const numberOfTicks = 8 * 1000; // min 8 seconds. - final EventLoopLatencyStats stats = - await measureEventLoopLatency(tickDuration, numberOfTicks); + final EventLoopLatencyStats stats = await measureEventLoopLatency( + tickDuration, + numberOfTicks, + ); // Kill isolate & wait until it's dead. isolate.kill(priority: Isolate.immediate); diff --git a/benchmarks/EventLoopLatencyRegexp/dart2/latency.dart b/benchmarks/EventLoopLatencyRegexp/dart2/latency.dart index 44ecae6001f..de43d974f79 100644 --- a/benchmarks/EventLoopLatencyRegexp/dart2/latency.dart +++ b/benchmarks/EventLoopLatencyRegexp/dart2/latency.dart @@ -16,7 +16,9 @@ import 'dart:typed_data'; /// /// Runs [numberOfTicks] times before completing with [EventLoopLatencyStats]. Future measureEventLoopLatency( - Duration tickDuration, int numberOfTicks) { + Duration tickDuration, + int numberOfTicks, +) { final completer = Completer(); final tickDurationInUs = tickDuration.inMicroseconds; @@ -75,14 +77,15 @@ class EventLoopLatencyStats { final int maxRss; EventLoopLatencyStats( - this.minLatency, - this.avgLatency, - this.maxLatency, - this.percentile50th, - this.percentile90th, - this.percentile95th, - this.percentile99th, - this.maxRss); + this.minLatency, + this.avgLatency, + this.maxLatency, + this.percentile50th, + this.percentile90th, + this.percentile95th, + this.percentile99th, + this.maxRss, + ); void report(String name) { print('$name.Min(RunTimeRaw): $minLatency ms.'); @@ -125,13 +128,14 @@ class _TickLatencies { final percentile99th = _timestamps[99 * length ~/ 100]; return EventLoopLatencyStats( - min / 1000, - avg / 1000, - max / 1000, - percentile50th / 1000, - percentile90th / 1000, - percentile95th / 1000, - percentile99th / 1000, - ProcessInfo.maxRss); + min / 1000, + avg / 1000, + max / 1000, + percentile50th / 1000, + percentile90th / 1000, + percentile95th / 1000, + percentile99th / 1000, + ProcessInfo.maxRss, + ); } } diff --git a/benchmarks/FfiAsTypedList/dart/FfiAsTypedList.dart b/benchmarks/FfiAsTypedList/dart/FfiAsTypedList.dart index 39d0e037568..fb548e56722 100644 --- a/benchmarks/FfiAsTypedList/dart/FfiAsTypedList.dart +++ b/benchmarks/FfiAsTypedList/dart/FfiAsTypedList.dart @@ -40,9 +40,7 @@ class FromPointerInt8 extends BenchmarkBase { // void main(List args) { - final benchmarks = [ - FromPointerInt8.new, - ]; + final benchmarks = [FromPointerInt8.new]; final filter = args.firstOrNull; for (var constructor in benchmarks) { diff --git a/benchmarks/FfiBoringssl/dart/FfiBoringssl.dart b/benchmarks/FfiBoringssl/dart/FfiBoringssl.dart index 018f33bc611..a41538bd7dc 100644 --- a/benchmarks/FfiBoringssl/dart/FfiBoringssl.dart +++ b/benchmarks/FfiBoringssl/dart/FfiBoringssl.dart @@ -139,10 +139,7 @@ class DigestDartMemory extends BenchmarkBase { // void main(List args) { - final benchmarks = [ - DigestCMemory.new, - DigestDartMemory.new, - ]; + final benchmarks = [DigestCMemory.new, DigestDartMemory.new]; final filter = args.firstOrNull; for (var constructor in benchmarks) { diff --git a/benchmarks/FfiBoringssl/dart/digest.dart b/benchmarks/FfiBoringssl/dart/digest.dart index 9af7617a83e..5b558ef3430 100644 --- a/benchmarks/FfiBoringssl/dart/digest.dart +++ b/benchmarks/FfiBoringssl/dart/digest.dart @@ -13,10 +13,14 @@ import 'types.dart'; DynamicLibrary openSsl() { // Force load crypto. - dlopenPlatformSpecific('crypto', - path: Platform.script.resolve('../native/out/').path); - final ssl = dlopenPlatformSpecific('ssl', - path: Platform.script.resolve('../native/out/').path); + dlopenPlatformSpecific( + 'crypto', + path: Platform.script.resolve('../native/out/').path, + ); + final ssl = dlopenPlatformSpecific( + 'ssl', + path: Platform.script.resolve('../native/out/').path, + ); return ssl; } @@ -28,9 +32,10 @@ final DynamicLibrary ssl = openSsl(); /// ```c /// const EVP_MD *EVP_sha512(void); /// ``` -final Pointer Function() EVP_sha512 = - ssl.lookupFunction Function(), Pointer Function()>( - 'EVP_sha512'); +final Pointer Function() EVP_sha512 = ssl + .lookupFunction Function(), Pointer Function()>( + 'EVP_sha512', + ); /// EVP_MD_CTX_new allocates and initialises a fresh EVP_MD_CTX and returns it, /// or NULL on allocation failure. The caller must use EVP_MD_CTX_free to @@ -40,8 +45,9 @@ final Pointer Function() EVP_sha512 = /// EVP_MD_CTX *EVP_MD_CTX_new(void); /// ``` final Pointer Function() EVP_MD_CTX_new = ssl.lookupFunction< - Pointer Function(), - Pointer Function()>('EVP_MD_CTX_new'); + Pointer Function(), + Pointer Function() +>('EVP_MD_CTX_new'); /// EVP_MD_CTX_free calls EVP_MD_CTX_cleanup and then frees ctx itself. /// @@ -49,8 +55,9 @@ final Pointer Function() EVP_MD_CTX_new = ssl.lookupFunction< /// void EVP_MD_CTX_free(EVP_MD_CTX *ctx); /// ``` final void Function(Pointer) EVP_MD_CTX_free = ssl.lookupFunction< - Void Function(Pointer), - void Function(Pointer)>('EVP_MD_CTX_free'); + Void Function(Pointer), + void Function(Pointer) +>('EVP_MD_CTX_free'); /// EVP_DigestInit acts like EVP_DigestInit_ex except that ctx is initialised /// before use. @@ -58,9 +65,11 @@ final void Function(Pointer) EVP_MD_CTX_free = ssl.lookupFunction< /// ```c /// int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); /// ``` -final int Function(Pointer, Pointer) EVP_DigestInit = - ssl.lookupFunction, Pointer), - int Function(Pointer, Pointer)>('EVP_DigestInit'); +final int Function(Pointer, Pointer) EVP_DigestInit = ssl + .lookupFunction< + Int32 Function(Pointer, Pointer), + int Function(Pointer, Pointer) + >('EVP_DigestInit'); /// EVP_DigestUpdate hashes len bytes from data into the hashing operation /// in ctx. It returns one. @@ -71,9 +80,9 @@ final int Function(Pointer, Pointer) EVP_DigestInit = /// ``` final int Function(Pointer, Pointer, int) EVP_DigestUpdate = ssl.lookupFunction< - Int32 Function(Pointer, Pointer, IntPtr), - int Function( - Pointer, Pointer, int)>('EVP_DigestUpdate'); + Int32 Function(Pointer, Pointer, IntPtr), + int Function(Pointer, Pointer, int) + >('EVP_DigestUpdate'); /// EVP_DigestFinal acts like EVP_DigestFinal_ex except that EVP_MD_CTX_cleanup /// is called on ctx before returning. @@ -83,10 +92,10 @@ final int Function(Pointer, Pointer, int) EVP_DigestUpdate = /// unsigned int *out_size); /// ``` final int Function(Pointer, Pointer, Pointer) - EVP_DigestFinal = ssl.lookupFunction< - Int32 Function(Pointer, Pointer, Pointer), - int Function(Pointer, Pointer, - Pointer)>('EVP_DigestFinal'); +EVP_DigestFinal = ssl.lookupFunction< + Int32 Function(Pointer, Pointer, Pointer), + int Function(Pointer, Pointer, Pointer) +>('EVP_DigestFinal'); /// EVP_MD_CTX_size returns the digest size of ctx, in bytes. It will crash if /// a digest hasn't been set on ctx. @@ -95,5 +104,6 @@ final int Function(Pointer, Pointer, Pointer) /// size_t EVP_MD_CTX_size(const EVP_MD_CTX *ctx); /// ``` final int Function(Pointer) EVP_MD_CTX_size = ssl.lookupFunction< - IntPtr Function(Pointer), - int Function(Pointer)>('EVP_MD_CTX_size'); + IntPtr Function(Pointer), + int Function(Pointer) +>('EVP_MD_CTX_size'); diff --git a/benchmarks/FfiCall/dart/FfiCall.dart b/benchmarks/FfiCall/dart/FfiCall.dart index fd1a15da503..2805bcd4515 100644 --- a/benchmarks/FfiCall/dart/FfiCall.dart +++ b/benchmarks/FfiCall/dart/FfiCall.dart @@ -19,14 +19,16 @@ part 'benchmark_generated.dart'; const N = 1000; // The native library that holds all the native functions being called. -DynamicLibrary ffiTestFunctions = dlopenPlatformSpecific('native_functions', - path: Platform.script.resolve('../native/out/').path); +DynamicLibrary ffiTestFunctions = dlopenPlatformSpecific( + 'native_functions', + path: Platform.script.resolve('../native/out/').path, +); abstract class FfiBenchmarkBase extends BenchmarkBase { final bool isLeaf; FfiBenchmarkBase(String name, {this.isLeaf = false}) - : super('$name${isLeaf ? 'Leaf' : ''}'); + : super('$name${isLeaf ? 'Leaf' : ''}'); void expectEquals(actual, expected) { if (actual != expected) { @@ -61,12 +63,19 @@ class Int64Mintx01 extends FfiBenchmarkBase { final Function1int f; Int64Mintx01({isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function1Int64', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function1Int64', isLeaf: false), - super('FfiCall.Int64Mintx01', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function1Int64', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function1Int64', + isLeaf: false, + ), + super('FfiCall.Int64Mintx01', isLeaf: isLeaf); @override void run() { @@ -85,8 +94,10 @@ class Int64Mintx01 extends FfiBenchmarkBase { void main(List args) { // Force loading the dylib with RLTD_GLOBAL so that the // Native benchmarks below can do process lookup. - dlopenGlobalPlatformSpecific('native_functions', - path: Platform.script.resolve('../native/out/').path); + dlopenGlobalPlatformSpecific( + 'native_functions', + path: Platform.script.resolve('../native/out/').path, + ); final benchmarks = [ Uint8x01.new, diff --git a/benchmarks/FfiCall/dart/benchmark_generated.dart b/benchmarks/FfiCall/dart/benchmark_generated.dart index 5505d3371da..814b953eac0 100644 --- a/benchmarks/FfiCall/dart/benchmark_generated.dart +++ b/benchmarks/FfiCall/dart/benchmark_generated.dart @@ -14,433 +14,637 @@ part of 'FfiCall.dart'; typedef Function1int = int Function(int); typedef Function2int = int Function(int, int); typedef Function4int = int Function(int, int, int, int); -typedef Function10int = int Function( - int, int, int, int, int, int, int, int, int, int); -typedef Function20int = int Function(int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int); +typedef Function10int = + int Function(int, int, int, int, int, int, int, int, int, int); +typedef Function20int = + int Function( + int, + int, + int, + int, + int, + int, + int, + int, + int, + int, + int, + int, + int, + int, + int, + int, + int, + int, + int, + int, + ); typedef Function1double = double Function(double); typedef Function2double = double Function(double, double); typedef Function4double = double Function(double, double, double, double); -typedef Function10double = double Function(double, double, double, double, - double, double, double, double, double, double); -typedef Function20double = double Function( - double, - double, - double, - double, - double, - double, - double, - double, - double, - double, - double, - double, - double, - double, - double, - double, - double, - double, - double, - double); +typedef Function10double = + double Function( + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + ); +typedef Function20double = + double Function( + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + ); typedef Function1PointerUint8 = Pointer Function(Pointer); -typedef Function2PointerUint8 = Pointer Function( - Pointer, Pointer); -typedef Function4PointerUint8 = Pointer Function( - Pointer, Pointer, Pointer, Pointer); -typedef Function10PointerUint8 = Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer); -typedef Function20PointerUint8 = Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer); +typedef Function2PointerUint8 = + Pointer Function(Pointer, Pointer); +typedef Function4PointerUint8 = + Pointer Function( + Pointer, + Pointer, + Pointer, + Pointer, + ); +typedef Function10PointerUint8 = + Pointer Function( + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + ); +typedef Function20PointerUint8 = + Pointer Function( + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + ); typedef Function1Object = Object Function(Object); typedef Function2Object = Object Function(Object, Object); typedef Function4Object = Object Function(Object, Object, Object, Object); -typedef Function10Object = Object Function(Object, Object, Object, Object, - Object, Object, Object, Object, Object, Object); -typedef Function20Object = Object Function( - Object, - Object, - Object, - Object, - Object, - Object, - Object, - Object, - Object, - Object, - Object, - Object, - Object, - Object, - Object, - Object, - Object, - Object, - Object, - Object); +typedef Function10Object = + Object Function( + Object, + Object, + Object, + Object, + Object, + Object, + Object, + Object, + Object, + Object, + ); +typedef Function20Object = + Object Function( + Object, + Object, + Object, + Object, + Object, + Object, + Object, + Object, + Object, + Object, + Object, + Object, + Object, + Object, + Object, + Object, + Object, + Object, + Object, + Object, + ); typedef NativeFunction1Int8 = Int8 Function(Int8); typedef NativeFunction2Int8 = Int8 Function(Int8, Int8); typedef NativeFunction4Int8 = Int8 Function(Int8, Int8, Int8, Int8); -typedef NativeFunction10Int8 = Int8 Function( - Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8); -typedef NativeFunction20Int8 = Int8 Function( - Int8, - Int8, - Int8, - Int8, - Int8, - Int8, - Int8, - Int8, - Int8, - Int8, - Int8, - Int8, - Int8, - Int8, - Int8, - Int8, - Int8, - Int8, - Int8, - Int8); +typedef NativeFunction10Int8 = + Int8 Function(Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8); +typedef NativeFunction20Int8 = + Int8 Function( + Int8, + Int8, + Int8, + Int8, + Int8, + Int8, + Int8, + Int8, + Int8, + Int8, + Int8, + Int8, + Int8, + Int8, + Int8, + Int8, + Int8, + Int8, + Int8, + Int8, + ); typedef NativeFunction1Int16 = Int16 Function(Int16); typedef NativeFunction2Int16 = Int16 Function(Int16, Int16); typedef NativeFunction4Int16 = Int16 Function(Int16, Int16, Int16, Int16); -typedef NativeFunction10Int16 = Int16 Function( - Int16, Int16, Int16, Int16, Int16, Int16, Int16, Int16, Int16, Int16); -typedef NativeFunction20Int16 = Int16 Function( - Int16, - Int16, - Int16, - Int16, - Int16, - Int16, - Int16, - Int16, - Int16, - Int16, - Int16, - Int16, - Int16, - Int16, - Int16, - Int16, - Int16, - Int16, - Int16, - Int16); +typedef NativeFunction10Int16 = + Int16 Function( + Int16, + Int16, + Int16, + Int16, + Int16, + Int16, + Int16, + Int16, + Int16, + Int16, + ); +typedef NativeFunction20Int16 = + Int16 Function( + Int16, + Int16, + Int16, + Int16, + Int16, + Int16, + Int16, + Int16, + Int16, + Int16, + Int16, + Int16, + Int16, + Int16, + Int16, + Int16, + Int16, + Int16, + Int16, + Int16, + ); typedef NativeFunction1Int32 = Int32 Function(Int32); typedef NativeFunction2Int32 = Int32 Function(Int32, Int32); typedef NativeFunction4Int32 = Int32 Function(Int32, Int32, Int32, Int32); -typedef NativeFunction10Int32 = Int32 Function( - Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32); -typedef NativeFunction20Int32 = Int32 Function( - Int32, - Int32, - Int32, - Int32, - Int32, - Int32, - Int32, - Int32, - Int32, - Int32, - Int32, - Int32, - Int32, - Int32, - Int32, - Int32, - Int32, - Int32, - Int32, - Int32); +typedef NativeFunction10Int32 = + Int32 Function( + Int32, + Int32, + Int32, + Int32, + Int32, + Int32, + Int32, + Int32, + Int32, + Int32, + ); +typedef NativeFunction20Int32 = + Int32 Function( + Int32, + Int32, + Int32, + Int32, + Int32, + Int32, + Int32, + Int32, + Int32, + Int32, + Int32, + Int32, + Int32, + Int32, + Int32, + Int32, + Int32, + Int32, + Int32, + Int32, + ); typedef NativeFunction1Int64 = Int64 Function(Int64); typedef NativeFunction2Int64 = Int64 Function(Int64, Int64); typedef NativeFunction4Int64 = Int64 Function(Int64, Int64, Int64, Int64); -typedef NativeFunction10Int64 = Int64 Function( - Int64, Int64, Int64, Int64, Int64, Int64, Int64, Int64, Int64, Int64); -typedef NativeFunction20Int64 = Int64 Function( - Int64, - Int64, - Int64, - Int64, - Int64, - Int64, - Int64, - Int64, - Int64, - Int64, - Int64, - Int64, - Int64, - Int64, - Int64, - Int64, - Int64, - Int64, - Int64, - Int64); +typedef NativeFunction10Int64 = + Int64 Function( + Int64, + Int64, + Int64, + Int64, + Int64, + Int64, + Int64, + Int64, + Int64, + Int64, + ); +typedef NativeFunction20Int64 = + Int64 Function( + Int64, + Int64, + Int64, + Int64, + Int64, + Int64, + Int64, + Int64, + Int64, + Int64, + Int64, + Int64, + Int64, + Int64, + Int64, + Int64, + Int64, + Int64, + Int64, + Int64, + ); typedef NativeFunction1Uint8 = Uint8 Function(Uint8); typedef NativeFunction2Uint8 = Uint8 Function(Uint8, Uint8); typedef NativeFunction4Uint8 = Uint8 Function(Uint8, Uint8, Uint8, Uint8); -typedef NativeFunction10Uint8 = Uint8 Function( - Uint8, Uint8, Uint8, Uint8, Uint8, Uint8, Uint8, Uint8, Uint8, Uint8); -typedef NativeFunction20Uint8 = Uint8 Function( - Uint8, - Uint8, - Uint8, - Uint8, - Uint8, - Uint8, - Uint8, - Uint8, - Uint8, - Uint8, - Uint8, - Uint8, - Uint8, - Uint8, - Uint8, - Uint8, - Uint8, - Uint8, - Uint8, - Uint8); +typedef NativeFunction10Uint8 = + Uint8 Function( + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + ); +typedef NativeFunction20Uint8 = + Uint8 Function( + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + Uint8, + ); typedef NativeFunction1Uint16 = Uint16 Function(Uint16); typedef NativeFunction2Uint16 = Uint16 Function(Uint16, Uint16); typedef NativeFunction4Uint16 = Uint16 Function(Uint16, Uint16, Uint16, Uint16); -typedef NativeFunction10Uint16 = Uint16 Function(Uint16, Uint16, Uint16, Uint16, - Uint16, Uint16, Uint16, Uint16, Uint16, Uint16); -typedef NativeFunction20Uint16 = Uint16 Function( - Uint16, - Uint16, - Uint16, - Uint16, - Uint16, - Uint16, - Uint16, - Uint16, - Uint16, - Uint16, - Uint16, - Uint16, - Uint16, - Uint16, - Uint16, - Uint16, - Uint16, - Uint16, - Uint16, - Uint16); +typedef NativeFunction10Uint16 = + Uint16 Function( + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + ); +typedef NativeFunction20Uint16 = + Uint16 Function( + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + Uint16, + ); typedef NativeFunction1Uint32 = Uint32 Function(Uint32); typedef NativeFunction2Uint32 = Uint32 Function(Uint32, Uint32); typedef NativeFunction4Uint32 = Uint32 Function(Uint32, Uint32, Uint32, Uint32); -typedef NativeFunction10Uint32 = Uint32 Function(Uint32, Uint32, Uint32, Uint32, - Uint32, Uint32, Uint32, Uint32, Uint32, Uint32); -typedef NativeFunction20Uint32 = Uint32 Function( - Uint32, - Uint32, - Uint32, - Uint32, - Uint32, - Uint32, - Uint32, - Uint32, - Uint32, - Uint32, - Uint32, - Uint32, - Uint32, - Uint32, - Uint32, - Uint32, - Uint32, - Uint32, - Uint32, - Uint32); +typedef NativeFunction10Uint32 = + Uint32 Function( + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + ); +typedef NativeFunction20Uint32 = + Uint32 Function( + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + Uint32, + ); typedef NativeFunction1Uint64 = Uint64 Function(Uint64); typedef NativeFunction2Uint64 = Uint64 Function(Uint64, Uint64); typedef NativeFunction4Uint64 = Uint64 Function(Uint64, Uint64, Uint64, Uint64); -typedef NativeFunction10Uint64 = Uint64 Function(Uint64, Uint64, Uint64, Uint64, - Uint64, Uint64, Uint64, Uint64, Uint64, Uint64); -typedef NativeFunction20Uint64 = Uint64 Function( - Uint64, - Uint64, - Uint64, - Uint64, - Uint64, - Uint64, - Uint64, - Uint64, - Uint64, - Uint64, - Uint64, - Uint64, - Uint64, - Uint64, - Uint64, - Uint64, - Uint64, - Uint64, - Uint64, - Uint64); +typedef NativeFunction10Uint64 = + Uint64 Function( + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + ); +typedef NativeFunction20Uint64 = + Uint64 Function( + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + Uint64, + ); typedef NativeFunction1Float = Float Function(Float); typedef NativeFunction2Float = Float Function(Float, Float); typedef NativeFunction4Float = Float Function(Float, Float, Float, Float); -typedef NativeFunction10Float = Float Function( - Float, Float, Float, Float, Float, Float, Float, Float, Float, Float); -typedef NativeFunction20Float = Float Function( - Float, - Float, - Float, - Float, - Float, - Float, - Float, - Float, - Float, - Float, - Float, - Float, - Float, - Float, - Float, - Float, - Float, - Float, - Float, - Float); +typedef NativeFunction10Float = + Float Function( + Float, + Float, + Float, + Float, + Float, + Float, + Float, + Float, + Float, + Float, + ); +typedef NativeFunction20Float = + Float Function( + Float, + Float, + Float, + Float, + Float, + Float, + Float, + Float, + Float, + Float, + Float, + Float, + Float, + Float, + Float, + Float, + Float, + Float, + Float, + Float, + ); typedef NativeFunction1Double = Double Function(Double); typedef NativeFunction2Double = Double Function(Double, Double); typedef NativeFunction4Double = Double Function(Double, Double, Double, Double); -typedef NativeFunction10Double = Double Function(Double, Double, Double, Double, - Double, Double, Double, Double, Double, Double); -typedef NativeFunction20Double = Double Function( - Double, - Double, - Double, - Double, - Double, - Double, - Double, - Double, - Double, - Double, - Double, - Double, - Double, - Double, - Double, - Double, - Double, - Double, - Double, - Double); +typedef NativeFunction10Double = + Double Function( + Double, + Double, + Double, + Double, + Double, + Double, + Double, + Double, + Double, + Double, + ); +typedef NativeFunction20Double = + Double Function( + Double, + Double, + Double, + Double, + Double, + Double, + Double, + Double, + Double, + Double, + Double, + Double, + Double, + Double, + Double, + Double, + Double, + Double, + Double, + Double, + ); typedef NativeFunction1PointerUint8 = Pointer Function(Pointer); -typedef NativeFunction2PointerUint8 = Pointer Function( - Pointer, Pointer); -typedef NativeFunction4PointerUint8 = Pointer Function( - Pointer, Pointer, Pointer, Pointer); -typedef NativeFunction10PointerUint8 = Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer); -typedef NativeFunction20PointerUint8 = Pointer Function( - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer, - Pointer); +typedef NativeFunction2PointerUint8 = + Pointer Function(Pointer, Pointer); +typedef NativeFunction4PointerUint8 = + Pointer Function( + Pointer, + Pointer, + Pointer, + Pointer, + ); +typedef NativeFunction10PointerUint8 = + Pointer Function( + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + ); +typedef NativeFunction20PointerUint8 = + Pointer Function( + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + Pointer, + ); typedef NativeFunction1Handle = Handle Function(Handle); typedef NativeFunction2Handle = Handle Function(Handle, Handle); typedef NativeFunction4Handle = Handle Function(Handle, Handle, Handle, Handle); -typedef NativeFunction10Handle = Handle Function(Handle, Handle, Handle, Handle, - Handle, Handle, Handle, Handle, Handle, Handle); -typedef NativeFunction20Handle = Handle Function( - Handle, - Handle, - Handle, - Handle, - Handle, - Handle, - Handle, - Handle, - Handle, - Handle, - Handle, - Handle, - Handle, - Handle, - Handle, - Handle, - Handle, - Handle, - Handle, - Handle); +typedef NativeFunction10Handle = + Handle Function( + Handle, + Handle, + Handle, + Handle, + Handle, + Handle, + Handle, + Handle, + Handle, + Handle, + ); +typedef NativeFunction20Handle = + Handle Function( + Handle, + Handle, + Handle, + Handle, + Handle, + Handle, + Handle, + Handle, + Handle, + Handle, + Handle, + Handle, + Handle, + Handle, + Handle, + Handle, + Handle, + Handle, + Handle, + Handle, + ); class Int8x01 extends FfiBenchmarkBase { final Function1int f; Int8x01({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function1Int8', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function1Int8', isLeaf: false), - super('FfiCall.Int8x01', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function1Int8', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function1Int8', + isLeaf: false, + ), + super('FfiCall.Int8x01', isLeaf: isLeaf); @override void run() { @@ -488,12 +692,19 @@ class Int16x01 extends FfiBenchmarkBase { final Function1int f; Int16x01({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function1Int16', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function1Int16', isLeaf: false), - super('FfiCall.Int16x01', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function1Int16', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function1Int16', + isLeaf: false, + ), + super('FfiCall.Int16x01', isLeaf: isLeaf); @override void run() { @@ -541,12 +752,19 @@ class Int32x01 extends FfiBenchmarkBase { final Function1int f; Int32x01({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function1Int32', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function1Int32', isLeaf: false), - super('FfiCall.Int32x01', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function1Int32', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function1Int32', + isLeaf: false, + ), + super('FfiCall.Int32x01', isLeaf: isLeaf); @override void run() { @@ -594,12 +812,19 @@ class Int32x02 extends FfiBenchmarkBase { final Function2int f; Int32x02({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function2Int32', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function2Int32', isLeaf: false), - super('FfiCall.Int32x02', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function2Int32', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function2Int32', + isLeaf: false, + ), + super('FfiCall.Int32x02', isLeaf: isLeaf); @override void run() { @@ -647,12 +872,19 @@ class Int32x04 extends FfiBenchmarkBase { final Function4int f; Int32x04({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function4Int32', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function4Int32', isLeaf: false), - super('FfiCall.Int32x04', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function4Int32', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function4Int32', + isLeaf: false, + ), + super('FfiCall.Int32x04', isLeaf: isLeaf); @override void run() { @@ -700,12 +932,19 @@ class Int32x10 extends FfiBenchmarkBase { final Function10int f; Int32x10({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function10Int32', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function10Int32', isLeaf: false), - super('FfiCall.Int32x10', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function10Int32', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function10Int32', + isLeaf: false, + ), + super('FfiCall.Int32x10', isLeaf: isLeaf); @override void run() { @@ -718,8 +957,18 @@ class Int32x10 extends FfiBenchmarkBase { } @Native(symbol: 'Function10Int32', isLeaf: false) -external int function10Int32(int a0, int a1, int a2, int a3, int a4, int a5, - int a6, int a7, int a8, int a9); +external int function10Int32( + int a0, + int a1, + int a2, + int a3, + int a4, + int a5, + int a6, + int a7, + int a8, + int a9, +); class Int32x10Native extends FfiBenchmarkBase { Int32x10Native() : super('FfiCall.Int32x10Native', isLeaf: false); @@ -735,8 +984,18 @@ class Int32x10Native extends FfiBenchmarkBase { } @Native(symbol: 'Function10Int32', isLeaf: true) -external int function10Int32Leaf(int a0, int a1, int a2, int a3, int a4, int a5, - int a6, int a7, int a8, int a9); +external int function10Int32Leaf( + int a0, + int a1, + int a2, + int a3, + int a4, + int a5, + int a6, + int a7, + int a8, + int a9, +); class Int32x10NativeLeaf extends FfiBenchmarkBase { Int32x10NativeLeaf() : super('FfiCall.Int32x10Native', isLeaf: true); @@ -755,12 +1014,19 @@ class Int32x20 extends FfiBenchmarkBase { final Function20int f; Int32x20({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function20Int32', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function20Int32', isLeaf: false), - super('FfiCall.Int32x20', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function20Int32', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function20Int32', + isLeaf: false, + ), + super('FfiCall.Int32x20', isLeaf: isLeaf); @override void run() { @@ -774,26 +1040,27 @@ class Int32x20 extends FfiBenchmarkBase { @Native(symbol: 'Function20Int32', isLeaf: false) external int function20Int32( - int a0, - int a1, - int a2, - int a3, - int a4, - int a5, - int a6, - int a7, - int a8, - int a9, - int a10, - int a11, - int a12, - int a13, - int a14, - int a15, - int a16, - int a17, - int a18, - int a19); + int a0, + int a1, + int a2, + int a3, + int a4, + int a5, + int a6, + int a7, + int a8, + int a9, + int a10, + int a11, + int a12, + int a13, + int a14, + int a15, + int a16, + int a17, + int a18, + int a19, +); class Int32x20Native extends FfiBenchmarkBase { Int32x20Native() : super('FfiCall.Int32x20Native', isLeaf: false); @@ -803,7 +1070,27 @@ class Int32x20Native extends FfiBenchmarkBase { int x = 0; for (int i = 0; i < N; i++) { x += function20Int32( - i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i); + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + ); } expectEquals(x, N * (N - 1) * 20 / 2); } @@ -811,26 +1098,27 @@ class Int32x20Native extends FfiBenchmarkBase { @Native(symbol: 'Function20Int32', isLeaf: true) external int function20Int32Leaf( - int a0, - int a1, - int a2, - int a3, - int a4, - int a5, - int a6, - int a7, - int a8, - int a9, - int a10, - int a11, - int a12, - int a13, - int a14, - int a15, - int a16, - int a17, - int a18, - int a19); + int a0, + int a1, + int a2, + int a3, + int a4, + int a5, + int a6, + int a7, + int a8, + int a9, + int a10, + int a11, + int a12, + int a13, + int a14, + int a15, + int a16, + int a17, + int a18, + int a19, +); class Int32x20NativeLeaf extends FfiBenchmarkBase { Int32x20NativeLeaf() : super('FfiCall.Int32x20Native', isLeaf: true); @@ -840,7 +1128,27 @@ class Int32x20NativeLeaf extends FfiBenchmarkBase { int x = 0; for (int i = 0; i < N; i++) { x += function20Int32Leaf( - i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i); + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + ); } expectEquals(x, N * (N - 1) * 20 / 2); } @@ -850,12 +1158,19 @@ class Int64x01 extends FfiBenchmarkBase { final Function1int f; Int64x01({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function1Int64', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function1Int64', isLeaf: false), - super('FfiCall.Int64x01', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function1Int64', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function1Int64', + isLeaf: false, + ), + super('FfiCall.Int64x01', isLeaf: isLeaf); @override void run() { @@ -903,12 +1218,19 @@ class Int64x02 extends FfiBenchmarkBase { final Function2int f; Int64x02({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function2Int64', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function2Int64', isLeaf: false), - super('FfiCall.Int64x02', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function2Int64', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function2Int64', + isLeaf: false, + ), + super('FfiCall.Int64x02', isLeaf: isLeaf); @override void run() { @@ -956,12 +1278,19 @@ class Int64x04 extends FfiBenchmarkBase { final Function4int f; Int64x04({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function4Int64', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function4Int64', isLeaf: false), - super('FfiCall.Int64x04', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function4Int64', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function4Int64', + isLeaf: false, + ), + super('FfiCall.Int64x04', isLeaf: isLeaf); @override void run() { @@ -1009,12 +1338,19 @@ class Int64x10 extends FfiBenchmarkBase { final Function10int f; Int64x10({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function10Int64', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function10Int64', isLeaf: false), - super('FfiCall.Int64x10', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function10Int64', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function10Int64', + isLeaf: false, + ), + super('FfiCall.Int64x10', isLeaf: isLeaf); @override void run() { @@ -1027,8 +1363,18 @@ class Int64x10 extends FfiBenchmarkBase { } @Native(symbol: 'Function10Int64', isLeaf: false) -external int function10Int64(int a0, int a1, int a2, int a3, int a4, int a5, - int a6, int a7, int a8, int a9); +external int function10Int64( + int a0, + int a1, + int a2, + int a3, + int a4, + int a5, + int a6, + int a7, + int a8, + int a9, +); class Int64x10Native extends FfiBenchmarkBase { Int64x10Native() : super('FfiCall.Int64x10Native', isLeaf: false); @@ -1044,8 +1390,18 @@ class Int64x10Native extends FfiBenchmarkBase { } @Native(symbol: 'Function10Int64', isLeaf: true) -external int function10Int64Leaf(int a0, int a1, int a2, int a3, int a4, int a5, - int a6, int a7, int a8, int a9); +external int function10Int64Leaf( + int a0, + int a1, + int a2, + int a3, + int a4, + int a5, + int a6, + int a7, + int a8, + int a9, +); class Int64x10NativeLeaf extends FfiBenchmarkBase { Int64x10NativeLeaf() : super('FfiCall.Int64x10Native', isLeaf: true); @@ -1064,12 +1420,19 @@ class Int64x20 extends FfiBenchmarkBase { final Function20int f; Int64x20({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function20Int64', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function20Int64', isLeaf: false), - super('FfiCall.Int64x20', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function20Int64', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function20Int64', + isLeaf: false, + ), + super('FfiCall.Int64x20', isLeaf: isLeaf); @override void run() { @@ -1083,26 +1446,27 @@ class Int64x20 extends FfiBenchmarkBase { @Native(symbol: 'Function20Int64', isLeaf: false) external int function20Int64( - int a0, - int a1, - int a2, - int a3, - int a4, - int a5, - int a6, - int a7, - int a8, - int a9, - int a10, - int a11, - int a12, - int a13, - int a14, - int a15, - int a16, - int a17, - int a18, - int a19); + int a0, + int a1, + int a2, + int a3, + int a4, + int a5, + int a6, + int a7, + int a8, + int a9, + int a10, + int a11, + int a12, + int a13, + int a14, + int a15, + int a16, + int a17, + int a18, + int a19, +); class Int64x20Native extends FfiBenchmarkBase { Int64x20Native() : super('FfiCall.Int64x20Native', isLeaf: false); @@ -1112,7 +1476,27 @@ class Int64x20Native extends FfiBenchmarkBase { int x = 0; for (int i = 0; i < N; i++) { x += function20Int64( - i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i); + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + ); } expectEquals(x, N * (N - 1) * 20 / 2); } @@ -1120,26 +1504,27 @@ class Int64x20Native extends FfiBenchmarkBase { @Native(symbol: 'Function20Int64', isLeaf: true) external int function20Int64Leaf( - int a0, - int a1, - int a2, - int a3, - int a4, - int a5, - int a6, - int a7, - int a8, - int a9, - int a10, - int a11, - int a12, - int a13, - int a14, - int a15, - int a16, - int a17, - int a18, - int a19); + int a0, + int a1, + int a2, + int a3, + int a4, + int a5, + int a6, + int a7, + int a8, + int a9, + int a10, + int a11, + int a12, + int a13, + int a14, + int a15, + int a16, + int a17, + int a18, + int a19, +); class Int64x20NativeLeaf extends FfiBenchmarkBase { Int64x20NativeLeaf() : super('FfiCall.Int64x20Native', isLeaf: true); @@ -1149,7 +1534,27 @@ class Int64x20NativeLeaf extends FfiBenchmarkBase { int x = 0; for (int i = 0; i < N; i++) { x += function20Int64Leaf( - i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i); + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + i, + ); } expectEquals(x, N * (N - 1) * 20 / 2); } @@ -1159,12 +1564,19 @@ class Uint8x01 extends FfiBenchmarkBase { final Function1int f; Uint8x01({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function1Uint8', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function1Uint8', isLeaf: false), - super('FfiCall.Uint8x01', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function1Uint8', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function1Uint8', + isLeaf: false, + ), + super('FfiCall.Uint8x01', isLeaf: isLeaf); @override void run() { @@ -1212,12 +1624,19 @@ class Uint16x01 extends FfiBenchmarkBase { final Function1int f; Uint16x01({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function1Uint16', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function1Uint16', isLeaf: false), - super('FfiCall.Uint16x01', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function1Uint16', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function1Uint16', + isLeaf: false, + ), + super('FfiCall.Uint16x01', isLeaf: isLeaf); @override void run() { @@ -1265,12 +1684,19 @@ class Uint32x01 extends FfiBenchmarkBase { final Function1int f; Uint32x01({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function1Uint32', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function1Uint32', isLeaf: false), - super('FfiCall.Uint32x01', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function1Uint32', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function1Uint32', + isLeaf: false, + ), + super('FfiCall.Uint32x01', isLeaf: isLeaf); @override void run() { @@ -1318,12 +1744,19 @@ class Uint64x01 extends FfiBenchmarkBase { final Function1int f; Uint64x01({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function1Uint64', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function1Uint64', isLeaf: false), - super('FfiCall.Uint64x01', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function1Uint64', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function1Uint64', + isLeaf: false, + ), + super('FfiCall.Uint64x01', isLeaf: isLeaf); @override void run() { @@ -1371,12 +1804,19 @@ class Floatx01 extends FfiBenchmarkBase { final Function1double f; Floatx01({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function1Float', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function1Float', isLeaf: false), - super('FfiCall.Floatx01', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function1Float', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function1Float', + isLeaf: false, + ), + super('FfiCall.Floatx01', isLeaf: isLeaf); @override void run() { @@ -1427,12 +1867,19 @@ class Floatx02 extends FfiBenchmarkBase { final Function2double f; Floatx02({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function2Float', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function2Float', isLeaf: false), - super('FfiCall.Floatx02', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function2Float', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function2Float', + isLeaf: false, + ), + super('FfiCall.Floatx02', isLeaf: isLeaf); @override void run() { @@ -1483,12 +1930,19 @@ class Floatx04 extends FfiBenchmarkBase { final Function4double f; Floatx04({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function4Float', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function4Float', isLeaf: false), - super('FfiCall.Floatx04', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function4Float', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function4Float', + isLeaf: false, + ), + super('FfiCall.Floatx04', isLeaf: isLeaf); @override void run() { @@ -1539,12 +1993,19 @@ class Floatx10 extends FfiBenchmarkBase { final Function10double f; Floatx10({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function10Float', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function10Float', isLeaf: false), - super('FfiCall.Floatx10', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function10Float', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function10Float', + isLeaf: false, + ), + super('FfiCall.Floatx10', isLeaf: isLeaf); @override void run() { @@ -1558,8 +2019,18 @@ class Floatx10 extends FfiBenchmarkBase { } @Native(symbol: 'Function10Float', isLeaf: false) -external double function10Float(double a0, double a1, double a2, double a3, - double a4, double a5, double a6, double a7, double a8, double a9); +external double function10Float( + double a0, + double a1, + double a2, + double a3, + double a4, + double a5, + double a6, + double a7, + double a8, + double a9, +); class Floatx10Native extends FfiBenchmarkBase { Floatx10Native() : super('FfiCall.Floatx10Native', isLeaf: false); @@ -1576,8 +2047,18 @@ class Floatx10Native extends FfiBenchmarkBase { } @Native(symbol: 'Function10Float', isLeaf: true) -external double function10FloatLeaf(double a0, double a1, double a2, double a3, - double a4, double a5, double a6, double a7, double a8, double a9); +external double function10FloatLeaf( + double a0, + double a1, + double a2, + double a3, + double a4, + double a5, + double a6, + double a7, + double a8, + double a9, +); class Floatx10NativeLeaf extends FfiBenchmarkBase { Floatx10NativeLeaf() : super('FfiCall.Floatx10Native', isLeaf: true); @@ -1587,7 +2068,17 @@ class Floatx10NativeLeaf extends FfiBenchmarkBase { double x = 0; for (int i = 0; i < N; i++) { x += function10FloatLeaf( - 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0); + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + ); } final double expected = N * 10 * (10 + 1) / 2; expectApprox(x, expected); @@ -1598,19 +2089,46 @@ class Floatx20 extends FfiBenchmarkBase { final Function20double f; Floatx20({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function20Float', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function20Float', isLeaf: false), - super('FfiCall.Floatx20', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function20Float', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function20Float', + isLeaf: false, + ), + super('FfiCall.Floatx20', isLeaf: isLeaf); @override void run() { double x = 0; for (int i = 0; i < N; i++) { - x += f(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, - 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0); + x += f( + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0, + 17.0, + 18.0, + 19.0, + 20.0, + ); } final double expected = N * 20 * (20 + 1) / 2; expectApprox(x, expected); @@ -1619,26 +2137,27 @@ class Floatx20 extends FfiBenchmarkBase { @Native(symbol: 'Function20Float', isLeaf: false) external double function20Float( - double a0, - double a1, - double a2, - double a3, - double a4, - double a5, - double a6, - double a7, - double a8, - double a9, - double a10, - double a11, - double a12, - double a13, - double a14, - double a15, - double a16, - double a17, - double a18, - double a19); + double a0, + double a1, + double a2, + double a3, + double a4, + double a5, + double a6, + double a7, + double a8, + double a9, + double a10, + double a11, + double a12, + double a13, + double a14, + double a15, + double a16, + double a17, + double a18, + double a19, +); class Floatx20Native extends FfiBenchmarkBase { Floatx20Native() : super('FfiCall.Floatx20Native', isLeaf: false); @@ -1647,8 +2166,28 @@ class Floatx20Native extends FfiBenchmarkBase { void run() { double x = 0; for (int i = 0; i < N; i++) { - x += function20Float(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, - 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0); + x += function20Float( + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0, + 17.0, + 18.0, + 19.0, + 20.0, + ); } final double expected = N * 20 * (20 + 1) / 2; expectApprox(x, expected); @@ -1657,26 +2196,27 @@ class Floatx20Native extends FfiBenchmarkBase { @Native(symbol: 'Function20Float', isLeaf: true) external double function20FloatLeaf( - double a0, - double a1, - double a2, - double a3, - double a4, - double a5, - double a6, - double a7, - double a8, - double a9, - double a10, - double a11, - double a12, - double a13, - double a14, - double a15, - double a16, - double a17, - double a18, - double a19); + double a0, + double a1, + double a2, + double a3, + double a4, + double a5, + double a6, + double a7, + double a8, + double a9, + double a10, + double a11, + double a12, + double a13, + double a14, + double a15, + double a16, + double a17, + double a18, + double a19, +); class Floatx20NativeLeaf extends FfiBenchmarkBase { Floatx20NativeLeaf() : super('FfiCall.Floatx20Native', isLeaf: true); @@ -1685,8 +2225,28 @@ class Floatx20NativeLeaf extends FfiBenchmarkBase { void run() { double x = 0; for (int i = 0; i < N; i++) { - x += function20FloatLeaf(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, - 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0); + x += function20FloatLeaf( + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0, + 17.0, + 18.0, + 19.0, + 20.0, + ); } final double expected = N * 20 * (20 + 1) / 2; expectApprox(x, expected); @@ -1697,12 +2257,19 @@ class Doublex01 extends FfiBenchmarkBase { final Function1double f; Doublex01({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function1Double', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function1Double', isLeaf: false), - super('FfiCall.Doublex01', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function1Double', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function1Double', + isLeaf: false, + ), + super('FfiCall.Doublex01', isLeaf: isLeaf); @override void run() { @@ -1753,12 +2320,19 @@ class Doublex02 extends FfiBenchmarkBase { final Function2double f; Doublex02({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function2Double', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function2Double', isLeaf: false), - super('FfiCall.Doublex02', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function2Double', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function2Double', + isLeaf: false, + ), + super('FfiCall.Doublex02', isLeaf: isLeaf); @override void run() { @@ -1809,12 +2383,19 @@ class Doublex04 extends FfiBenchmarkBase { final Function4double f; Doublex04({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function4Double', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function4Double', isLeaf: false), - super('FfiCall.Doublex04', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function4Double', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function4Double', + isLeaf: false, + ), + super('FfiCall.Doublex04', isLeaf: isLeaf); @override void run() { @@ -1865,12 +2446,19 @@ class Doublex10 extends FfiBenchmarkBase { final Function10double f; Doublex10({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function10Double', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function10Double', isLeaf: false), - super('FfiCall.Doublex10', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function10Double', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function10Double', + isLeaf: false, + ), + super('FfiCall.Doublex10', isLeaf: isLeaf); @override void run() { @@ -1884,8 +2472,18 @@ class Doublex10 extends FfiBenchmarkBase { } @Native(symbol: 'Function10Double', isLeaf: false) -external double function10Double(double a0, double a1, double a2, double a3, - double a4, double a5, double a6, double a7, double a8, double a9); +external double function10Double( + double a0, + double a1, + double a2, + double a3, + double a4, + double a5, + double a6, + double a7, + double a8, + double a9, +); class Doublex10Native extends FfiBenchmarkBase { Doublex10Native() : super('FfiCall.Doublex10Native', isLeaf: false); @@ -1902,8 +2500,18 @@ class Doublex10Native extends FfiBenchmarkBase { } @Native(symbol: 'Function10Double', isLeaf: true) -external double function10DoubleLeaf(double a0, double a1, double a2, double a3, - double a4, double a5, double a6, double a7, double a8, double a9); +external double function10DoubleLeaf( + double a0, + double a1, + double a2, + double a3, + double a4, + double a5, + double a6, + double a7, + double a8, + double a9, +); class Doublex10NativeLeaf extends FfiBenchmarkBase { Doublex10NativeLeaf() : super('FfiCall.Doublex10Native', isLeaf: true); @@ -1913,7 +2521,17 @@ class Doublex10NativeLeaf extends FfiBenchmarkBase { double x = 0; for (int i = 0; i < N; i++) { x += function10DoubleLeaf( - 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0); + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + ); } final double expected = N * 10 * (10 + 1) / 2; expectApprox(x, expected); @@ -1924,19 +2542,46 @@ class Doublex20 extends FfiBenchmarkBase { final Function20double f; Doublex20({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function20Double', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function20Double', isLeaf: false), - super('FfiCall.Doublex20', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions + .lookupFunction( + 'Function20Double', + isLeaf: true, + ) + : ffiTestFunctions + .lookupFunction( + 'Function20Double', + isLeaf: false, + ), + super('FfiCall.Doublex20', isLeaf: isLeaf); @override void run() { double x = 0; for (int i = 0; i < N; i++) { - x += f(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, - 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0); + x += f( + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0, + 17.0, + 18.0, + 19.0, + 20.0, + ); } final double expected = N * 20 * (20 + 1) / 2; expectApprox(x, expected); @@ -1945,26 +2590,27 @@ class Doublex20 extends FfiBenchmarkBase { @Native(symbol: 'Function20Double', isLeaf: false) external double function20Double( - double a0, - double a1, - double a2, - double a3, - double a4, - double a5, - double a6, - double a7, - double a8, - double a9, - double a10, - double a11, - double a12, - double a13, - double a14, - double a15, - double a16, - double a17, - double a18, - double a19); + double a0, + double a1, + double a2, + double a3, + double a4, + double a5, + double a6, + double a7, + double a8, + double a9, + double a10, + double a11, + double a12, + double a13, + double a14, + double a15, + double a16, + double a17, + double a18, + double a19, +); class Doublex20Native extends FfiBenchmarkBase { Doublex20Native() : super('FfiCall.Doublex20Native', isLeaf: false); @@ -1973,8 +2619,28 @@ class Doublex20Native extends FfiBenchmarkBase { void run() { double x = 0; for (int i = 0; i < N; i++) { - x += function20Double(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, - 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0); + x += function20Double( + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0, + 17.0, + 18.0, + 19.0, + 20.0, + ); } final double expected = N * 20 * (20 + 1) / 2; expectApprox(x, expected); @@ -1983,26 +2649,27 @@ class Doublex20Native extends FfiBenchmarkBase { @Native(symbol: 'Function20Double', isLeaf: true) external double function20DoubleLeaf( - double a0, - double a1, - double a2, - double a3, - double a4, - double a5, - double a6, - double a7, - double a8, - double a9, - double a10, - double a11, - double a12, - double a13, - double a14, - double a15, - double a16, - double a17, - double a18, - double a19); + double a0, + double a1, + double a2, + double a3, + double a4, + double a5, + double a6, + double a7, + double a8, + double a9, + double a10, + double a11, + double a12, + double a13, + double a14, + double a15, + double a16, + double a17, + double a18, + double a19, +); class Doublex20NativeLeaf extends FfiBenchmarkBase { Doublex20NativeLeaf() : super('FfiCall.Doublex20Native', isLeaf: true); @@ -2011,8 +2678,28 @@ class Doublex20NativeLeaf extends FfiBenchmarkBase { void run() { double x = 0; for (int i = 0; i < N; i++) { - x += function20DoubleLeaf(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, - 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0); + x += function20DoubleLeaf( + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0, + 17.0, + 18.0, + 19.0, + 20.0, + ); } final double expected = N * 20 * (20 + 1) / 2; expectApprox(x, expected); @@ -2023,12 +2710,17 @@ class PointerUint8x01 extends FfiBenchmarkBase { final Function1PointerUint8 f; PointerUint8x01({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function1PointerUint8', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function1PointerUint8', isLeaf: false), - super('FfiCall.PointerUint8x01', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions.lookupFunction< + NativeFunction1PointerUint8, + Function1PointerUint8 + >('Function1PointerUint8', isLeaf: true) + : ffiTestFunctions.lookupFunction< + NativeFunction1PointerUint8, + Function1PointerUint8 + >('Function1PointerUint8', isLeaf: false), + super('FfiCall.PointerUint8x01', isLeaf: isLeaf); Pointer p1 = nullptr; @@ -2046,21 +2738,21 @@ class PointerUint8x01 extends FfiBenchmarkBase { void run() { Pointer x = p1; for (int i = 0; i < N; i++) { - x = f( - x, - ); + x = f(x); } expectEquals(x.address, p1.address + N * sizeOf()); } } @Native( - symbol: 'Function1PointerUint8', isLeaf: false) + symbol: 'Function1PointerUint8', + isLeaf: false, +) external Pointer function1PointerUint8(Pointer a0); class PointerUint8x01Native extends FfiBenchmarkBase { PointerUint8x01Native() - : super('FfiCall.PointerUint8x01Native', isLeaf: false); + : super('FfiCall.PointerUint8x01Native', isLeaf: false); Pointer p1 = nullptr; @@ -2078,21 +2770,21 @@ class PointerUint8x01Native extends FfiBenchmarkBase { void run() { Pointer x = p1; for (int i = 0; i < N; i++) { - x = function1PointerUint8( - x, - ); + x = function1PointerUint8(x); } expectEquals(x.address, p1.address + N * sizeOf()); } } @Native( - symbol: 'Function1PointerUint8', isLeaf: true) + symbol: 'Function1PointerUint8', + isLeaf: true, +) external Pointer function1PointerUint8Leaf(Pointer a0); class PointerUint8x01NativeLeaf extends FfiBenchmarkBase { PointerUint8x01NativeLeaf() - : super('FfiCall.PointerUint8x01Native', isLeaf: true); + : super('FfiCall.PointerUint8x01Native', isLeaf: true); Pointer p1 = nullptr; @@ -2110,9 +2802,7 @@ class PointerUint8x01NativeLeaf extends FfiBenchmarkBase { void run() { Pointer x = p1; for (int i = 0; i < N; i++) { - x = function1PointerUint8Leaf( - x, - ); + x = function1PointerUint8Leaf(x); } expectEquals(x.address, p1.address + N * sizeOf()); } @@ -2122,12 +2812,17 @@ class PointerUint8x02 extends FfiBenchmarkBase { final Function2PointerUint8 f; PointerUint8x02({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function2PointerUint8', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function2PointerUint8', isLeaf: false), - super('FfiCall.PointerUint8x02', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions.lookupFunction< + NativeFunction2PointerUint8, + Function2PointerUint8 + >('Function2PointerUint8', isLeaf: true) + : ffiTestFunctions.lookupFunction< + NativeFunction2PointerUint8, + Function2PointerUint8 + >('Function2PointerUint8', isLeaf: false), + super('FfiCall.PointerUint8x02', isLeaf: isLeaf); Pointer p1 = nullptr; Pointer p2 = nullptr; @@ -2154,13 +2849,17 @@ class PointerUint8x02 extends FfiBenchmarkBase { } @Native( - symbol: 'Function2PointerUint8', isLeaf: false) + symbol: 'Function2PointerUint8', + isLeaf: false, +) external Pointer function2PointerUint8( - Pointer a0, Pointer a1); + Pointer a0, + Pointer a1, +); class PointerUint8x02Native extends FfiBenchmarkBase { PointerUint8x02Native() - : super('FfiCall.PointerUint8x02Native', isLeaf: false); + : super('FfiCall.PointerUint8x02Native', isLeaf: false); Pointer p1 = nullptr; Pointer p2 = nullptr; @@ -2187,13 +2886,17 @@ class PointerUint8x02Native extends FfiBenchmarkBase { } @Native( - symbol: 'Function2PointerUint8', isLeaf: true) + symbol: 'Function2PointerUint8', + isLeaf: true, +) external Pointer function2PointerUint8Leaf( - Pointer a0, Pointer a1); + Pointer a0, + Pointer a1, +); class PointerUint8x02NativeLeaf extends FfiBenchmarkBase { PointerUint8x02NativeLeaf() - : super('FfiCall.PointerUint8x02Native', isLeaf: true); + : super('FfiCall.PointerUint8x02Native', isLeaf: true); Pointer p1 = nullptr; Pointer p2 = nullptr; @@ -2223,12 +2926,17 @@ class PointerUint8x04 extends FfiBenchmarkBase { final Function4PointerUint8 f; PointerUint8x04({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function4PointerUint8', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function4PointerUint8', isLeaf: false), - super('FfiCall.PointerUint8x04', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions.lookupFunction< + NativeFunction4PointerUint8, + Function4PointerUint8 + >('Function4PointerUint8', isLeaf: true) + : ffiTestFunctions.lookupFunction< + NativeFunction4PointerUint8, + Function4PointerUint8 + >('Function4PointerUint8', isLeaf: false), + super('FfiCall.PointerUint8x04', isLeaf: isLeaf); Pointer p1 = nullptr; Pointer p2 = nullptr; @@ -2259,13 +2967,19 @@ class PointerUint8x04 extends FfiBenchmarkBase { } @Native( - symbol: 'Function4PointerUint8', isLeaf: false) + symbol: 'Function4PointerUint8', + isLeaf: false, +) external Pointer function4PointerUint8( - Pointer a0, Pointer a1, Pointer a2, Pointer a3); + Pointer a0, + Pointer a1, + Pointer a2, + Pointer a3, +); class PointerUint8x04Native extends FfiBenchmarkBase { PointerUint8x04Native() - : super('FfiCall.PointerUint8x04Native', isLeaf: false); + : super('FfiCall.PointerUint8x04Native', isLeaf: false); Pointer p1 = nullptr; Pointer p2 = nullptr; @@ -2296,13 +3010,19 @@ class PointerUint8x04Native extends FfiBenchmarkBase { } @Native( - symbol: 'Function4PointerUint8', isLeaf: true) + symbol: 'Function4PointerUint8', + isLeaf: true, +) external Pointer function4PointerUint8Leaf( - Pointer a0, Pointer a1, Pointer a2, Pointer a3); + Pointer a0, + Pointer a1, + Pointer a2, + Pointer a3, +); class PointerUint8x04NativeLeaf extends FfiBenchmarkBase { PointerUint8x04NativeLeaf() - : super('FfiCall.PointerUint8x04Native', isLeaf: true); + : super('FfiCall.PointerUint8x04Native', isLeaf: true); Pointer p1 = nullptr; Pointer p2 = nullptr; @@ -2336,13 +3056,17 @@ class PointerUint8x10 extends FfiBenchmarkBase { final Function10PointerUint8 f; PointerUint8x10({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function10PointerUint8', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function10PointerUint8', - isLeaf: false), - super('FfiCall.PointerUint8x10', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions.lookupFunction< + NativeFunction10PointerUint8, + Function10PointerUint8 + >('Function10PointerUint8', isLeaf: true) + : ffiTestFunctions.lookupFunction< + NativeFunction10PointerUint8, + Function10PointerUint8 + >('Function10PointerUint8', isLeaf: false), + super('FfiCall.PointerUint8x10', isLeaf: isLeaf); Pointer p1 = nullptr; Pointer p2 = nullptr; @@ -2385,22 +3109,25 @@ class PointerUint8x10 extends FfiBenchmarkBase { } @Native( - symbol: 'Function10PointerUint8', isLeaf: false) + symbol: 'Function10PointerUint8', + isLeaf: false, +) external Pointer function10PointerUint8( - Pointer a0, - Pointer a1, - Pointer a2, - Pointer a3, - Pointer a4, - Pointer a5, - Pointer a6, - Pointer a7, - Pointer a8, - Pointer a9); + Pointer a0, + Pointer a1, + Pointer a2, + Pointer a3, + Pointer a4, + Pointer a5, + Pointer a6, + Pointer a7, + Pointer a8, + Pointer a9, +); class PointerUint8x10Native extends FfiBenchmarkBase { PointerUint8x10Native() - : super('FfiCall.PointerUint8x10Native', isLeaf: false); + : super('FfiCall.PointerUint8x10Native', isLeaf: false); Pointer p1 = nullptr; Pointer p2 = nullptr; @@ -2443,22 +3170,25 @@ class PointerUint8x10Native extends FfiBenchmarkBase { } @Native( - symbol: 'Function10PointerUint8', isLeaf: true) + symbol: 'Function10PointerUint8', + isLeaf: true, +) external Pointer function10PointerUint8Leaf( - Pointer a0, - Pointer a1, - Pointer a2, - Pointer a3, - Pointer a4, - Pointer a5, - Pointer a6, - Pointer a7, - Pointer a8, - Pointer a9); + Pointer a0, + Pointer a1, + Pointer a2, + Pointer a3, + Pointer a4, + Pointer a5, + Pointer a6, + Pointer a7, + Pointer a8, + Pointer a9, +); class PointerUint8x10NativeLeaf extends FfiBenchmarkBase { PointerUint8x10NativeLeaf() - : super('FfiCall.PointerUint8x10Native', isLeaf: true); + : super('FfiCall.PointerUint8x10Native', isLeaf: true); Pointer p1 = nullptr; Pointer p2 = nullptr; @@ -2504,13 +3234,17 @@ class PointerUint8x20 extends FfiBenchmarkBase { final Function20PointerUint8 f; PointerUint8x20({bool isLeaf = false}) - : f = isLeaf - ? ffiTestFunctions.lookupFunction('Function20PointerUint8', isLeaf: true) - : ffiTestFunctions.lookupFunction('Function20PointerUint8', - isLeaf: false), - super('FfiCall.PointerUint8x20', isLeaf: isLeaf); + : f = + isLeaf + ? ffiTestFunctions.lookupFunction< + NativeFunction20PointerUint8, + Function20PointerUint8 + >('Function20PointerUint8', isLeaf: true) + : ffiTestFunctions.lookupFunction< + NativeFunction20PointerUint8, + Function20PointerUint8 + >('Function20PointerUint8', isLeaf: false), + super('FfiCall.PointerUint8x20', isLeaf: isLeaf); Pointer p1 = nullptr; Pointer p2 = nullptr; @@ -2566,40 +3300,63 @@ class PointerUint8x20 extends FfiBenchmarkBase { void run() { Pointer x = p1; for (int i = 0; i < N; i++) { - x = f(x, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, - p16, p17, p18, p19, p20); + x = f( + x, + p2, + p3, + p4, + p5, + p6, + p7, + p8, + p9, + p10, + p11, + p12, + p13, + p14, + p15, + p16, + p17, + p18, + p19, + p20, + ); } expectEquals(x.address, p1.address + N * sizeOf()); } } @Native( - symbol: 'Function20PointerUint8', isLeaf: false) + symbol: 'Function20PointerUint8', + isLeaf: false, +) external Pointer function20PointerUint8( - Pointer a0, - Pointer a1, - Pointer a2, - Pointer a3, - Pointer a4, - Pointer a5, - Pointer a6, - Pointer a7, - Pointer a8, - Pointer a9, - Pointer a10, - Pointer a11, - Pointer a12, - Pointer a13, - Pointer a14, - Pointer a15, - Pointer a16, - Pointer a17, - Pointer a18, - Pointer a19); + Pointer a0, + Pointer a1, + Pointer a2, + Pointer a3, + Pointer a4, + Pointer a5, + Pointer a6, + Pointer a7, + Pointer a8, + Pointer a9, + Pointer a10, + Pointer a11, + Pointer a12, + Pointer a13, + Pointer a14, + Pointer a15, + Pointer a16, + Pointer a17, + Pointer a18, + Pointer a19, +); class PointerUint8x20Native extends FfiBenchmarkBase { PointerUint8x20Native() - : super('FfiCall.PointerUint8x20Native', isLeaf: false); + : super('FfiCall.PointerUint8x20Native', isLeaf: false); Pointer p1 = nullptr; Pointer p2 = nullptr; @@ -2655,40 +3412,63 @@ class PointerUint8x20Native extends FfiBenchmarkBase { void run() { Pointer x = p1; for (int i = 0; i < N; i++) { - x = function20PointerUint8(x, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, - p12, p13, p14, p15, p16, p17, p18, p19, p20); + x = function20PointerUint8( + x, + p2, + p3, + p4, + p5, + p6, + p7, + p8, + p9, + p10, + p11, + p12, + p13, + p14, + p15, + p16, + p17, + p18, + p19, + p20, + ); } expectEquals(x.address, p1.address + N * sizeOf()); } } @Native( - symbol: 'Function20PointerUint8', isLeaf: true) + symbol: 'Function20PointerUint8', + isLeaf: true, +) external Pointer function20PointerUint8Leaf( - Pointer a0, - Pointer a1, - Pointer a2, - Pointer a3, - Pointer a4, - Pointer a5, - Pointer a6, - Pointer a7, - Pointer a8, - Pointer a9, - Pointer a10, - Pointer a11, - Pointer a12, - Pointer a13, - Pointer a14, - Pointer a15, - Pointer a16, - Pointer a17, - Pointer a18, - Pointer a19); + Pointer a0, + Pointer a1, + Pointer a2, + Pointer a3, + Pointer a4, + Pointer a5, + Pointer a6, + Pointer a7, + Pointer a8, + Pointer a9, + Pointer a10, + Pointer a11, + Pointer a12, + Pointer a13, + Pointer a14, + Pointer a15, + Pointer a16, + Pointer a17, + Pointer a18, + Pointer a19, +); class PointerUint8x20NativeLeaf extends FfiBenchmarkBase { PointerUint8x20NativeLeaf() - : super('FfiCall.PointerUint8x20Native', isLeaf: true); + : super('FfiCall.PointerUint8x20Native', isLeaf: true); Pointer p1 = nullptr; Pointer p2 = nullptr; @@ -2744,8 +3524,28 @@ class PointerUint8x20NativeLeaf extends FfiBenchmarkBase { void run() { Pointer x = p1; for (int i = 0; i < N; i++) { - x = function20PointerUint8Leaf(x, p2, p3, p4, p5, p6, p7, p8, p9, p10, - p11, p12, p13, p14, p15, p16, p17, p18, p19, p20); + x = function20PointerUint8Leaf( + x, + p2, + p3, + p4, + p5, + p6, + p7, + p8, + p9, + p10, + p11, + p12, + p13, + p14, + p15, + p16, + p17, + p18, + p19, + p20, + ); } expectEquals(x.address, p1.address + N * sizeOf()); } @@ -2755,9 +3555,12 @@ class Handlex01 extends FfiBenchmarkBase { final Function1Object f; Handlex01() - : f = ffiTestFunctions.lookupFunction('Function1Handle', isLeaf: false), - super('FfiCall.Handlex01', isLeaf: false); + : f = ffiTestFunctions + .lookupFunction( + 'Function1Handle', + isLeaf: false, + ), + super('FfiCall.Handlex01', isLeaf: false); @override void run() { @@ -2765,9 +3568,7 @@ class Handlex01 extends FfiBenchmarkBase { Object x = m1; for (int i = 0; i < N; i++) { - x = f( - x, - ); + x = f(x); } expectIdentical(x, m1); } @@ -2785,9 +3586,7 @@ class Handlex01Native extends FfiBenchmarkBase { Object x = m1; for (int i = 0; i < N; i++) { - x = function1Handle( - x, - ); + x = function1Handle(x); } expectIdentical(x, m1); } @@ -2797,9 +3596,12 @@ class Handlex02 extends FfiBenchmarkBase { final Function2Object f; Handlex02() - : f = ffiTestFunctions.lookupFunction('Function2Handle', isLeaf: false), - super('FfiCall.Handlex02', isLeaf: false); + : f = ffiTestFunctions + .lookupFunction( + 'Function2Handle', + isLeaf: false, + ), + super('FfiCall.Handlex02', isLeaf: false); @override void run() { @@ -2835,9 +3637,12 @@ class Handlex04 extends FfiBenchmarkBase { final Function4Object f; Handlex04() - : f = ffiTestFunctions.lookupFunction('Function4Handle', isLeaf: false), - super('FfiCall.Handlex04', isLeaf: false); + : f = ffiTestFunctions + .lookupFunction( + 'Function4Handle', + isLeaf: false, + ), + super('FfiCall.Handlex04', isLeaf: false); @override void run() { @@ -2877,9 +3682,12 @@ class Handlex10 extends FfiBenchmarkBase { final Function10Object f; Handlex10() - : f = ffiTestFunctions.lookupFunction('Function10Handle', isLeaf: false), - super('FfiCall.Handlex10', isLeaf: false); + : f = ffiTestFunctions + .lookupFunction( + 'Function10Handle', + isLeaf: false, + ), + super('FfiCall.Handlex10', isLeaf: false); @override void run() { @@ -2902,8 +3710,18 @@ class Handlex10 extends FfiBenchmarkBase { } @Native(symbol: 'Function10Handle', isLeaf: false) -external Object function10Handle(Object a0, Object a1, Object a2, Object a3, - Object a4, Object a5, Object a6, Object a7, Object a8, Object a9); +external Object function10Handle( + Object a0, + Object a1, + Object a2, + Object a3, + Object a4, + Object a5, + Object a6, + Object a7, + Object a8, + Object a9, +); class Handlex10Native extends FfiBenchmarkBase { Handlex10Native() : super('FfiCall.Handlex10Native', isLeaf: false); @@ -2932,9 +3750,12 @@ class Handlex20 extends FfiBenchmarkBase { final Function20Object f; Handlex20() - : f = ffiTestFunctions.lookupFunction('Function20Handle', isLeaf: false), - super('FfiCall.Handlex20', isLeaf: false); + : f = ffiTestFunctions + .lookupFunction( + 'Function20Handle', + isLeaf: false, + ), + super('FfiCall.Handlex20', isLeaf: false); @override void run() { @@ -2960,8 +3781,28 @@ class Handlex20 extends FfiBenchmarkBase { final m20 = MyClass(20); Object x = m1; for (int i = 0; i < N; i++) { - x = f(x, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, - m16, m17, m18, m19, m20); + x = f( + x, + m2, + m3, + m4, + m5, + m6, + m7, + m8, + m9, + m10, + m11, + m12, + m13, + m14, + m15, + m16, + m17, + m18, + m19, + m20, + ); } expectIdentical(x, m1); } @@ -2969,26 +3810,27 @@ class Handlex20 extends FfiBenchmarkBase { @Native(symbol: 'Function20Handle', isLeaf: false) external Object function20Handle( - Object a0, - Object a1, - Object a2, - Object a3, - Object a4, - Object a5, - Object a6, - Object a7, - Object a8, - Object a9, - Object a10, - Object a11, - Object a12, - Object a13, - Object a14, - Object a15, - Object a16, - Object a17, - Object a18, - Object a19); + Object a0, + Object a1, + Object a2, + Object a3, + Object a4, + Object a5, + Object a6, + Object a7, + Object a8, + Object a9, + Object a10, + Object a11, + Object a12, + Object a13, + Object a14, + Object a15, + Object a16, + Object a17, + Object a18, + Object a19, +); class Handlex20Native extends FfiBenchmarkBase { Handlex20Native() : super('FfiCall.Handlex20Native', isLeaf: false); @@ -3017,8 +3859,28 @@ class Handlex20Native extends FfiBenchmarkBase { final m20 = MyClass(20); Object x = m1; for (int i = 0; i < N; i++) { - x = function20Handle(x, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, - m13, m14, m15, m16, m17, m18, m19, m20); + x = function20Handle( + x, + m2, + m3, + m4, + m5, + m6, + m7, + m8, + m9, + m10, + m11, + m12, + m13, + m14, + m15, + m16, + m17, + m18, + m19, + m20, + ); } expectIdentical(x, m1); } diff --git a/benchmarks/FfiCall/dart/dlopen_helper.dart b/benchmarks/FfiCall/dart/dlopen_helper.dart index 05e7a30a278..2c061527181 100644 --- a/benchmarks/FfiCall/dart/dlopen_helper.dart +++ b/benchmarks/FfiCall/dart/dlopen_helper.dart @@ -72,9 +72,10 @@ const RTLD_GLOBAL_android_arm32 = 0x00002; /// On Linux and Android Arm64. const RTLD_GLOBAL_rest = 0x00100; -final RTLD_GLOBAL = Abi.current() == Abi.androidArm - ? RTLD_GLOBAL_android_arm32 - : RTLD_GLOBAL_rest; +final RTLD_GLOBAL = + Abi.current() == Abi.androidArm + ? RTLD_GLOBAL_android_arm32 + : RTLD_GLOBAL_rest; @Native Function(Pointer, Int)>() external Pointer dlopen(Pointer file, int mode); @@ -84,8 +85,9 @@ Object dlopenGlobalPlatformSpecific(String name, {String path = ''}) { // TODO(https://dartbug.com/50105): enable dlopen global via package:ffi. return using((arena) { final dylibHandle = dlopen( - _platformPath(name, path).toNativeUtf8(allocator: arena).cast(), - RTLD_LAZY | RTLD_GLOBAL); + _platformPath(name, path).toNativeUtf8(allocator: arena).cast(), + RTLD_LAZY | RTLD_GLOBAL, + ); return dylibHandle; }); } diff --git a/benchmarks/FfiCall/generate_benchmarks.dart b/benchmarks/FfiCall/generate_benchmarks.dart index 91e5398f3ce..52087a8ca6a 100644 --- a/benchmarks/FfiCall/generate_benchmarks.dart +++ b/benchmarks/FfiCall/generate_benchmarks.dart @@ -82,8 +82,12 @@ part of 'FfiCall.dart'; '''; -void generateTypedefs(StringBuffer buffer, String namePrefix, - List types, List numbers) { +void generateTypedefs( + StringBuffer buffer, + String namePrefix, + List types, + List numbers, +) { for (String type in types) { for (int number in numbers) { final String name = '$namePrefix$number${toIdentifier(type)}'; @@ -106,8 +110,10 @@ void generateBenchmarkInt(StringBuffer buffer, List types) { final String argument = IntVariation(type, number).argument; final String arguments = repeat(argument, number, ', '); final String functionNameDart = 'function$number$typeName'; - final String dartArguments = - List.generate(number, (i) => '$dartType a$i').join(', '); + final String dartArguments = List.generate( + number, + (i) => '$dartType a$i', + ).join(', '); buffer.write(''' class $name extends FfiBenchmarkBase { @@ -160,17 +166,20 @@ void generateBenchmarkDouble(StringBuffer buffer, List types) { final String dartType = toIdentifier(nativeToDartType[type]!); for (int number in generateFor[type]!) { final String name = '${typeName}x${'$number'.padLeft(2, '0')}'; - final String expected = number == 1 - ? 'N + N * 42.0' // Do work with single arg. - : 'N * $number * ($number + 1) / 2 '; // The rest sums arguments. + final String expected = + number == 1 + ? 'N + N * 42.0' // Do work with single arg. + : 'N * $number * ($number + 1) / 2 '; // The rest sums arguments. final String functionType = 'Function$number$dartType'; final String functionNativeType = 'NativeFunction$number$typeName'; final String functionNameC = 'Function$number$typeName'; final List argVals = List.generate(number, (i) => 1.0 * (i + 1)); final String arguments = argVals.join(', '); final String functionNameDart = 'function$number$typeName'; - final String dartArguments = - List.generate(number, (i) => '$dartType a$i').join(', '); + final String dartArguments = List.generate( + number, + (i) => '$dartType a$i', + ).join(', '); buffer.write(''' class $name extends FfiBenchmarkBase { final $functionType f; @@ -226,19 +235,27 @@ void generateBenchmarkPointer(StringBuffer buffer, List types) { final String dartTypeName = toIdentifier(dartType); for (int number in generateFor[type]!) { final String name = '${typeName}x${'$number'.padLeft(2, '0')}'; - final List pointerNames = - List.generate(number, (i) => 'p${i + 1}'); - final String pointers = - pointerNames.map((n) => '$type $n = nullptr;').join('\n'); - final String setup = List.generate( - number - 1, (i) => 'p${i + 2} = p1.elementAt(${i + 1});').join(); + final List pointerNames = List.generate( + number, + (i) => 'p${i + 1}', + ); + final String pointers = pointerNames + .map((n) => '$type $n = nullptr;') + .join('\n'); + final String setup = + List.generate( + number - 1, + (i) => 'p${i + 2} = p1.elementAt(${i + 1});', + ).join(); final String functionType = 'Function$number$dartTypeName'; final String functionNativeType = 'NativeFunction$number$typeName'; final String functionNameC = 'Function$number$typeName'; final String arguments = pointerNames.skip(1).join(', '); final String functionNameDart = 'function$number$typeName'; - final String dartArguments = - List.generate(number, (i) => '$dartType a$i').join(', '); + final String dartArguments = List.generate( + number, + (i) => '$dartType a$i', + ).join(', '); buffer.write(''' class $name extends FfiBenchmarkBase { final $functionType f; @@ -317,18 +334,22 @@ void generateBenchmarkHandle(StringBuffer buffer, List types) { final String dartType = toIdentifier(nativeToDartType[type]!); for (int number in generateFor[type]!) { final String name = '${typeName}x${'$number'.padLeft(2, '0')}'; - final String setup = - List.generate(number + 1, (i) => 'final m$i = MyClass($i);') - .skip(2) - .join('\n'); + final String setup = List.generate( + number + 1, + (i) => 'final m$i = MyClass($i);', + ).skip(2).join('\n'); final String functionType = 'Function$number$dartType'; final String functionNativeType = 'NativeFunction$number$typeName'; final String functionNameC = 'Function$number$typeName'; - final String arguments = - List.generate(number - 1, (i) => 'm${i + 2}').join(', '); + final String arguments = List.generate( + number - 1, + (i) => 'm${i + 2}', + ).join(', '); final String functionNameDart = 'function$number$typeName'; - final String dartArguments = - List.generate(number, (i) => '$dartType a$i').join(', '); + final String dartArguments = List.generate( + number, + (i) => '$dartType a$i', + ).join(', '); buffer.write(''' class $name extends FfiBenchmarkBase { final $functionType f; @@ -385,21 +406,21 @@ class IntVariation { /// These benchmarks sum all arguments over all iterations. IntVariation.LargeIntManyArguments() - : argument = 'i', - expectedValue = ((int number) => 'N * (N - 1) * $number / 2'); + : argument = 'i', + expectedValue = ((int number) => 'N * (N - 1) * $number / 2'); /// Benchmarks with only one argument return 42 added to the argument. IntVariation.LargeIntOneArgument() - : argument = 'i', - expectedValue = ((int number) => 'N * (N - 1) / 2 + N * 42'); + : argument = 'i', + expectedValue = ((int number) => 'N * (N - 1) / 2 + N * 42'); /// The benchmarks with small ints (`int8_t`, `uint8_t`, etc.) we pass an /// arbitrary fixed argument between 0 and 127 to prevent truncation. /// /// The C function returns 42 added to the argument. IntVariation.SmallInt() - : argument = '17', - expectedValue = ((int number) => 'N * 17 + N * 42'); + : argument = '17', + expectedValue = ((int number) => 'N * 17 + N * 42'); factory IntVariation(String type, int number) { if (isSmallInt(type)) { diff --git a/benchmarks/FfiMemory/dart/FfiMemory.dart b/benchmarks/FfiMemory/dart/FfiMemory.dart index 83ac8ba1f90..98cf1c36a82 100644 --- a/benchmarks/FfiMemory/dart/FfiMemory.dart +++ b/benchmarks/FfiMemory/dart/FfiMemory.dart @@ -92,7 +92,10 @@ void doStoreDouble(Pointer pointer, int length) { } void doStorePointer( - Pointer> pointer, int length, Pointer data) { + Pointer> pointer, + int length, + Pointer data, +) { for (int i = 0; i < length; i++) { pointer[i] = data; } diff --git a/benchmarks/FfiStruct/dart/FfiStruct.dart b/benchmarks/FfiStruct/dart/FfiStruct.dart index dad52fa31b3..5a94c4a0059 100644 --- a/benchmarks/FfiStruct/dart/FfiStruct.dart +++ b/benchmarks/FfiStruct/dart/FfiStruct.dart @@ -69,9 +69,7 @@ class FieldLoadStore extends BenchmarkBase { // void main(List args) { - final benchmarks = [ - FieldLoadStore.new, - ]; + final benchmarks = [FieldLoadStore.new]; final filter = args.firstOrNull; for (var constructor in benchmarks) { diff --git a/benchmarks/FfiStruct/dart2/FfiStruct.dart b/benchmarks/FfiStruct/dart2/FfiStruct.dart index 87f98de9b3d..15bb53ad3a2 100644 --- a/benchmarks/FfiStruct/dart2/FfiStruct.dart +++ b/benchmarks/FfiStruct/dart2/FfiStruct.dart @@ -71,9 +71,7 @@ class FieldLoadStore extends BenchmarkBase { // void main() { - final benchmarks = [ - () => FieldLoadStore(), - ]; + final benchmarks = [() => FieldLoadStore()]; for (final benchmark in benchmarks) { benchmark().report(); } diff --git a/benchmarks/FfiStructCopy/dart/FfiStructCopy.dart b/benchmarks/FfiStructCopy/dart/FfiStructCopy.dart index 88d0dc61215..cee50796c61 100644 --- a/benchmarks/FfiStructCopy/dart/FfiStructCopy.dart +++ b/benchmarks/FfiStructCopy/dart/FfiStructCopy.dart @@ -83,8 +83,13 @@ abstract class StructCopyBenchmark { void run(int batchSize); } -final argParser = ArgParser() - ..addFlag('verbose', abbr: 'v', help: 'Verbose output', defaultsTo: false); +final argParser = + ArgParser()..addFlag( + 'verbose', + abbr: 'v', + help: 'Verbose output', + defaultsTo: false, + ); void main(List args) { final results = argParser.parse(args); diff --git a/benchmarks/FfiStructCopy/generate_benchmarks.dart b/benchmarks/FfiStructCopy/generate_benchmarks.dart index 77f40e68703..e07c0747fe3 100644 --- a/benchmarks/FfiStructCopy/generate_benchmarks.dart +++ b/benchmarks/FfiStructCopy/generate_benchmarks.dart @@ -15,12 +15,7 @@ Future main() async { await File.fromUri(uri).writeAsString(contents); } -const sizes = [ - 1, - 32, - 1024, - 1024 * 32, -]; +const sizes = [1, 32, 1024, 1024 * 32]; const header = '''// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file diff --git a/benchmarks/FileIOSink/dart/FileIOSink.dart b/benchmarks/FileIOSink/dart/FileIOSink.dart index ff89b4d81e5..8fd1537cfab 100644 --- a/benchmarks/FileIOSink/dart/FileIOSink.dart +++ b/benchmarks/FileIOSink/dart/FileIOSink.dart @@ -83,8 +83,10 @@ class BenchmarkAlternatingSizedAdd extends AsyncBenchmarkBase { @override Future setup() async { _tempDir = Directory.systemTemp.createTempSync(); - _ioSink = File(_tempDir.uri.resolve('alternative-add-size').toFilePath()) - .openWrite(); + _ioSink = + File( + _tempDir.uri.resolve('alternative-add-size').toFilePath(), + ).openWrite(); } @override diff --git a/benchmarks/FunctionToJs/dart/FunctionToJs.dart b/benchmarks/FunctionToJs/dart/FunctionToJs.dart index c714cd0684d..d0ca90ba0ef 100644 --- a/benchmarks/FunctionToJs/dart/FunctionToJs.dart +++ b/benchmarks/FunctionToJs/dart/FunctionToJs.dart @@ -32,16 +32,17 @@ import 'package:benchmark_harness/benchmark_harness.dart'; external set cache(JSFunction jsFunction); extension on JSFunction { - external int call( - [JSAny? thisArg, - int? arg1, - int? arg2, - int? arg3, - int? arg4, - int? arg5, - int? arg6, - int? arg7, - int? arg8]); + external int call([ + JSAny? thisArg, + int? arg1, + int? arg2, + int? arg3, + int? arg4, + int? arg5, + int? arg6, + int? arg7, + int? arg8, + ]); } final random = math.Random(); @@ -80,9 +81,16 @@ class ConvertInstanceEightBenchmark extends BenchmarkBase { final int randomInt = random.nextInt(10); @pragma('dart2js:never-inline') - int eight(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, - int arg7, int arg8) => - randomInt + arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8; + int eight( + int arg1, + int arg2, + int arg3, + int arg4, + int arg5, + int arg6, + int arg7, + int arg8, + ) => randomInt + arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8; @override void run() { @@ -121,9 +129,16 @@ class ConvertStaticEightBenchmark extends BenchmarkBase { static final int randomInt = random.nextInt(10); - static int eight(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, - int arg7, int arg8) => - randomInt + arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8; + static int eight( + int arg1, + int arg2, + int arg3, + int arg4, + int arg5, + int arg6, + int arg7, + int arg8, + ) => randomInt + arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8; @override void run() { @@ -160,15 +175,33 @@ class ConvertClosureEightBenchmark extends BenchmarkBase { @override void run() { - cache = ((int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, - int arg7, int arg8) => - randomInt + arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8).toJS; + cache = + (( + int arg1, + int arg2, + int arg3, + int arg4, + int arg5, + int arg6, + int arg7, + int arg8, + ) => + randomInt + + arg1 + + arg2 + + arg3 + + arg4 + + arg5 + + arg6 + + arg7 + + arg8) + .toJS; } } class ConvertClosureFieldZeroBenchmark extends BenchmarkBase { ConvertClosureFieldZeroBenchmark() - : super('FunctionToJs.Convert.ClosureField.0'); + : super('FunctionToJs.Convert.ClosureField.0'); late int Function() closure; final int randomInt = random.nextInt(10); @@ -186,7 +219,7 @@ class ConvertClosureFieldZeroBenchmark extends BenchmarkBase { class ConvertClosureFieldTwoBenchmark extends BenchmarkBase { ConvertClosureFieldTwoBenchmark() - : super('FunctionToJs.Convert.ClosureField.2'); + : super('FunctionToJs.Convert.ClosureField.2'); late int Function(int, int) closure; final int randomInt = random.nextInt(10); @@ -204,16 +237,24 @@ class ConvertClosureFieldTwoBenchmark extends BenchmarkBase { class ConvertClosureFieldEightBenchmark extends BenchmarkBase { ConvertClosureFieldEightBenchmark() - : super('FunctionToJs.Convert.ClosureField.8'); + : super('FunctionToJs.Convert.ClosureField.8'); late int Function(int, int, int, int, int, int, int, int) closure; final int randomInt = random.nextInt(10); @override void setup() { - closure = (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, - int arg7, int arg8) => - randomInt + arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8; + closure = + ( + int arg1, + int arg2, + int arg3, + int arg4, + int arg5, + int arg6, + int arg7, + int arg8, + ) => randomInt + arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8; } @override @@ -271,9 +312,16 @@ class CallJSInstanceEightBenchmark extends BenchmarkBase { final int randomInt = random.nextInt(10); @pragma('dart2js:never-inline') - int eight(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, - int arg7, int arg8) => - randomInt + arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8; + int eight( + int arg1, + int arg2, + int arg3, + int arg4, + int arg5, + int arg6, + int arg7, + int arg8, + ) => randomInt + arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8; @override void setup() { @@ -334,9 +382,16 @@ class CallJSStaticEightBenchmark extends BenchmarkBase { static final int randomInt = random.nextInt(10); - static int eight(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, - int arg7, int arg8) => - randomInt + arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8; + static int eight( + int arg1, + int arg2, + int arg3, + int arg4, + int arg5, + int arg6, + int arg7, + int arg8, + ) => randomInt + arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8; late JSExportedDartFunction jsFunction; @@ -396,9 +451,27 @@ class CallJSClosureEightBenchmark extends BenchmarkBase { @override void setup() { - jsFunction = ((int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, - int arg7, int arg8) => - randomInt + arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8).toJS; + jsFunction = + (( + int arg1, + int arg2, + int arg3, + int arg4, + int arg5, + int arg6, + int arg7, + int arg8, + ) => + randomInt + + arg1 + + arg2 + + arg3 + + arg4 + + arg5 + + arg6 + + arg7 + + arg8) + .toJS; } @override @@ -452,9 +525,17 @@ class CallDartClosureEightBenchmark extends BenchmarkBase { @override void setup() { - closure = (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, - int arg7, int arg8) => - randomInt + arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8; + closure = + ( + int arg1, + int arg2, + int arg3, + int arg4, + int arg5, + int arg6, + int arg7, + int arg8, + ) => randomInt + arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8; } @override diff --git a/benchmarks/InstantiateTypeArgs/generate.dart b/benchmarks/InstantiateTypeArgs/generate.dart index c24766a8f9d..1366bbd1d2b 100644 --- a/benchmarks/InstantiateTypeArgs/generate.dart +++ b/benchmarks/InstantiateTypeArgs/generate.dart @@ -93,13 +93,19 @@ class C$i {} void main() { final dartFilePath = path.join( - path.dirname(Platform.script.path), 'dart', '$benchmarkName.dart'); + path.dirname(Platform.script.path), + 'dart', + '$benchmarkName.dart', + ); final dartSink = File(dartFilePath).openWrite(); generateBenchmarkClassesAndUtilities(dartSink, nnbd: true); dartSink..flush(); final dart2FilePath = path.join( - path.dirname(Platform.script.path), 'dart2', '$benchmarkName.dart'); + path.dirname(Platform.script.path), + 'dart2', + '$benchmarkName.dart', + ); final dart2Sink = File(dart2FilePath).openWrite(); generateBenchmarkClassesAndUtilities(dart2Sink, nnbd: false); dart2Sink..flush(); diff --git a/benchmarks/IntegerSetLookup/dart/IntegerSetLookup.dart b/benchmarks/IntegerSetLookup/dart/IntegerSetLookup.dart index d0c7af1c28a..7184e078bed 100644 --- a/benchmarks/IntegerSetLookup/dart/IntegerSetLookup.dart +++ b/benchmarks/IntegerSetLookup/dart/IntegerSetLookup.dart @@ -24,7 +24,7 @@ class SetBenchmark extends BenchmarkBase { void main() { final list = [ - for (int i = 0; i < 14790; i++) (i + 1) * 0x10000000 + 123456789 + for (int i = 0; i < 14790; i++) (i + 1) * 0x10000000 + 123456789, ]; final r = Random(); @@ -37,7 +37,9 @@ void main() { () => SetBenchmark('IntegerSetLookup.DefaultHashSet_Random', {...randomList}), () => SetBenchmark( - 'IntegerSetLookup.HashSet_Random', HashSet()..addAll(randomList)), + 'IntegerSetLookup.HashSet_Random', + HashSet()..addAll(randomList), + ), ]; for (final benchmark in benchmarks) { benchmark().report(); diff --git a/benchmarks/IntegerSetLookup/dart2/IntegerSetLookup.dart b/benchmarks/IntegerSetLookup/dart2/IntegerSetLookup.dart index 3a297922e1c..351530493fe 100644 --- a/benchmarks/IntegerSetLookup/dart2/IntegerSetLookup.dart +++ b/benchmarks/IntegerSetLookup/dart2/IntegerSetLookup.dart @@ -25,7 +25,7 @@ class SetBenchmark extends BenchmarkBase { void main() { final list = [ - for (int i = 0; i < 14790; i++) (i + 1) * 0x10000000 + 123456789 + for (int i = 0; i < 14790; i++) (i + 1) * 0x10000000 + 123456789, ]; final r = Random(); @@ -38,7 +38,9 @@ void main() { () => SetBenchmark("IntegerSetLookup.DefaultHashSet_Random", {...randomList}), () => SetBenchmark( - "IntegerSetLookup.HashSet_Random", HashSet()..addAll(randomList)), + "IntegerSetLookup.HashSet_Random", + HashSet()..addAll(randomList), + ), ]; for (final benchmark in benchmarks) { benchmark().report(); diff --git a/benchmarks/Isolate/dart/Isolate.dart b/benchmarks/Isolate/dart/Isolate.dart index 55e53779c80..840e4f19ca0 100644 --- a/benchmarks/Isolate/dart/Isolate.dart +++ b/benchmarks/Isolate/dart/Isolate.dart @@ -9,9 +9,11 @@ import 'dart:typed_data'; import 'package:benchmark_harness/benchmark_harness.dart'; class SendReceiveBytes extends AsyncBenchmarkBase { - SendReceiveBytes(String name, - {required this.size, required this.useTransferable}) - : super(name); + SendReceiveBytes( + String name, { + required this.size, + required this.useTransferable, + }) : super(name); @override Future run() async { @@ -52,11 +54,13 @@ class SendReceiveHelper { port = ReceivePort(); inbox = StreamIterator(port); workerCompleted = Completer(); - workerExitedPort = ReceivePort() - ..listen((_) => workerCompleted.complete(true)); + workerExitedPort = + ReceivePort()..listen((_) => workerCompleted.complete(true)); worker = await Isolate.spawn( - isolate, StartMessage(port.sendPort, useTransferable, size), - onExit: workerExitedPort.sendPort); + isolate, + StartMessage(port.sendPort, useTransferable, size), + onExit: workerExitedPort.sendPort, + ); await inbox.moveNext(); outbox = inbox.current; } @@ -127,18 +131,20 @@ const List sizes = [ SizeName(100 * 1024, '100KB'), SizeName(1 * 1024 * 1024, '1MB'), SizeName(10 * 1024 * 1024, '10MB'), - SizeName(100 * 1024 * 1024, '100MB') + SizeName(100 * 1024 * 1024, '100MB'), ]; Future main() async { for (final sizeName in sizes) { - await SendReceiveBytes('Isolate.SendReceiveBytes${sizeName.name}', - size: sizeName.size, useTransferable: false) - .report(); await SendReceiveBytes( - 'Isolate.SendReceiveBytesTransferable${sizeName.name}', - size: sizeName.size, - useTransferable: true) - .report(); + 'Isolate.SendReceiveBytes${sizeName.name}', + size: sizeName.size, + useTransferable: false, + ).report(); + await SendReceiveBytes( + 'Isolate.SendReceiveBytesTransferable${sizeName.name}', + size: sizeName.size, + useTransferable: true, + ).report(); } } diff --git a/benchmarks/Isolate/dart2/Isolate.dart b/benchmarks/Isolate/dart2/Isolate.dart index c8bfaabadfc..cfc31d93a9f 100644 --- a/benchmarks/Isolate/dart2/Isolate.dart +++ b/benchmarks/Isolate/dart2/Isolate.dart @@ -12,9 +12,11 @@ import 'package:benchmark_harness/benchmark_harness.dart'; import 'package:meta/meta.dart'; class SendReceiveBytes extends AsyncBenchmarkBase { - SendReceiveBytes(String name, - {@required this.size, @required this.useTransferable}) - : super(name); + SendReceiveBytes( + String name, { + @required this.size, + @required this.useTransferable, + }) : super(name); @override Future run() async { @@ -55,11 +57,13 @@ class SendReceiveHelper { port = ReceivePort(); inbox = StreamIterator(port); workerCompleted = Completer(); - workerExitedPort = ReceivePort() - ..listen((_) => workerCompleted.complete(true)); + workerExitedPort = + ReceivePort()..listen((_) => workerCompleted.complete(true)); worker = await Isolate.spawn( - isolate, StartMessage(port.sendPort, useTransferable, size), - onExit: workerExitedPort.sendPort); + isolate, + StartMessage(port.sendPort, useTransferable, size), + onExit: workerExitedPort.sendPort, + ); await inbox.moveNext(); outbox = inbox.current; } @@ -130,18 +134,20 @@ const List sizes = [ SizeName(100 * 1024, '100KB'), SizeName(1 * 1024 * 1024, '1MB'), SizeName(10 * 1024 * 1024, '10MB'), - SizeName(100 * 1024 * 1024, '100MB') + SizeName(100 * 1024 * 1024, '100MB'), ]; Future main() async { for (final sizeName in sizes) { - await SendReceiveBytes('Isolate.SendReceiveBytes${sizeName.name}', - size: sizeName.size, useTransferable: false) - .report(); await SendReceiveBytes( - 'Isolate.SendReceiveBytesTransferable${sizeName.name}', - size: sizeName.size, - useTransferable: true) - .report(); + 'Isolate.SendReceiveBytes${sizeName.name}', + size: sizeName.size, + useTransferable: false, + ).report(); + await SendReceiveBytes( + 'Isolate.SendReceiveBytesTransferable${sizeName.name}', + size: sizeName.size, + useTransferable: true, + ).report(); } } diff --git a/benchmarks/IsolateBaseOverhead/dart/IsolateBaseOverhead.dart b/benchmarks/IsolateBaseOverhead/dart/IsolateBaseOverhead.dart index c9b8d2475e8..5d9fe03ac8e 100644 --- a/benchmarks/IsolateBaseOverhead/dart/IsolateBaseOverhead.dart +++ b/benchmarks/IsolateBaseOverhead/dart/IsolateBaseOverhead.dart @@ -17,8 +17,11 @@ void main() async { final lastIsolatePort = ReceivePort(); final startRss = ProcessInfo.currentRss; final startUs = DateTime.now().microsecondsSinceEpoch; - await Isolate.spawn(worker, WorkerInfo(count, lastIsolatePort.sendPort), - onExit: onDone.sendPort); + await Isolate.spawn( + worker, + WorkerInfo(count, lastIsolatePort.sendPort), + onExit: onDone.sendPort, + ); final result = await lastIsolatePort.first as List; final lastIsolateRss = result[0] as int; final lastIsolateUs = result[1] as int; @@ -31,9 +34,11 @@ void main() async { print('IsolateBaseOverhead.Rss(MemoryUse): $averageMemoryUsageInKB'); print( - 'IsolateBaseOverhead.StartLatency(Latency): $averageStartLatencyInUs us.'); + 'IsolateBaseOverhead.StartLatency(Latency): $averageStartLatencyInUs us.', + ); print( - 'IsolateBaseOverhead.FinishLatency(Latency): $averageFinishLatencyInUs us.'); + 'IsolateBaseOverhead.FinishLatency(Latency): $averageFinishLatencyInUs us.', + ); } class WorkerInfo { @@ -45,12 +50,17 @@ class WorkerInfo { Future worker(WorkerInfo workerInfo) async { if (workerInfo.id == 1) { - workerInfo.result - .send([ProcessInfo.currentRss, DateTime.now().microsecondsSinceEpoch]); + workerInfo.result.send([ + ProcessInfo.currentRss, + DateTime.now().microsecondsSinceEpoch, + ]); return; } final onExit = ReceivePort(); - await Isolate.spawn(worker, WorkerInfo(workerInfo.id - 1, workerInfo.result), - onExit: onExit.sendPort); + await Isolate.spawn( + worker, + WorkerInfo(workerInfo.id - 1, workerInfo.result), + onExit: onExit.sendPort, + ); await onExit.first; } diff --git a/benchmarks/IsolateBaseOverhead/dart2/IsolateBaseOverhead.dart b/benchmarks/IsolateBaseOverhead/dart2/IsolateBaseOverhead.dart index c9b8d2475e8..5d9fe03ac8e 100644 --- a/benchmarks/IsolateBaseOverhead/dart2/IsolateBaseOverhead.dart +++ b/benchmarks/IsolateBaseOverhead/dart2/IsolateBaseOverhead.dart @@ -17,8 +17,11 @@ void main() async { final lastIsolatePort = ReceivePort(); final startRss = ProcessInfo.currentRss; final startUs = DateTime.now().microsecondsSinceEpoch; - await Isolate.spawn(worker, WorkerInfo(count, lastIsolatePort.sendPort), - onExit: onDone.sendPort); + await Isolate.spawn( + worker, + WorkerInfo(count, lastIsolatePort.sendPort), + onExit: onDone.sendPort, + ); final result = await lastIsolatePort.first as List; final lastIsolateRss = result[0] as int; final lastIsolateUs = result[1] as int; @@ -31,9 +34,11 @@ void main() async { print('IsolateBaseOverhead.Rss(MemoryUse): $averageMemoryUsageInKB'); print( - 'IsolateBaseOverhead.StartLatency(Latency): $averageStartLatencyInUs us.'); + 'IsolateBaseOverhead.StartLatency(Latency): $averageStartLatencyInUs us.', + ); print( - 'IsolateBaseOverhead.FinishLatency(Latency): $averageFinishLatencyInUs us.'); + 'IsolateBaseOverhead.FinishLatency(Latency): $averageFinishLatencyInUs us.', + ); } class WorkerInfo { @@ -45,12 +50,17 @@ class WorkerInfo { Future worker(WorkerInfo workerInfo) async { if (workerInfo.id == 1) { - workerInfo.result - .send([ProcessInfo.currentRss, DateTime.now().microsecondsSinceEpoch]); + workerInfo.result.send([ + ProcessInfo.currentRss, + DateTime.now().microsecondsSinceEpoch, + ]); return; } final onExit = ReceivePort(); - await Isolate.spawn(worker, WorkerInfo(workerInfo.id - 1, workerInfo.result), - onExit: onExit.sendPort); + await Isolate.spawn( + worker, + WorkerInfo(workerInfo.id - 1, workerInfo.result), + onExit: onExit.sendPort, + ); await onExit.first; } diff --git a/benchmarks/IsolateJson/dart/IsolateJson.dart b/benchmarks/IsolateJson/dart/IsolateJson.dart index bc13e057c50..0bc83876bb3 100644 --- a/benchmarks/IsolateJson/dart/IsolateJson.dart +++ b/benchmarks/IsolateJson/dart/IsolateJson.dart @@ -11,10 +11,12 @@ import 'dart:typed_data'; import 'package:benchmark_harness/benchmark_harness.dart' show BenchmarkBase; class JsonDecodingBenchmark { - JsonDecodingBenchmark(this.name, - {required this.sample, - required this.numTasks, - required this.useSendAndExit}); + JsonDecodingBenchmark( + this.name, { + required this.sample, + required this.numTasks, + required this.useSendAndExit, + }); Future report() async { final stopwatch = Stopwatch()..start(); @@ -63,9 +65,12 @@ Future decodeJson(bool useSendAndExit, Uint8List encodedJson) async { stderr.writeln('worker errored out $v'); completer.completeError(true); }); - await Isolate.spawn(jsonDecodingIsolate, - JsonDecodeRequest(useSendAndExit, port.sendPort, encodedJson), - onError: workerErroredPort.sendPort, onExit: workerExitedPort.sendPort); + await Isolate.spawn( + jsonDecodingIsolate, + JsonDecodeRequest(useSendAndExit, port.sendPort, encodedJson), + onError: workerErroredPort.sendPort, + onExit: workerExitedPort.sendPort, + ); await completer.future; workerExitedPort.close(); workerErroredPort.close(); @@ -85,9 +90,11 @@ Future jsonDecodingIsolate(JsonDecodeRequest request) async { } class SyncJsonDecodingBenchmark extends BenchmarkBase { - SyncJsonDecodingBenchmark(String name, - {required this.sample, required this.iterations}) - : super(name); + SyncJsonDecodingBenchmark( + String name, { + required this.sample, + required this.iterations, + }) : super(name); @override void run() { @@ -137,22 +144,22 @@ Future main() async { for (final config in configs) { for (final iterations in [1, 4]) { await JsonDecodingBenchmark( - 'IsolateJson.Decode${config.suffix}x$iterations', - useSendAndExit: false, - sample: config.sample, - numTasks: iterations) - .report(); + 'IsolateJson.Decode${config.suffix}x$iterations', + useSendAndExit: false, + sample: config.sample, + numTasks: iterations, + ).report(); await JsonDecodingBenchmark( - 'IsolateJson.SendAndExit_Decode${config.suffix}x$iterations', - useSendAndExit: true, - sample: config.sample, - numTasks: iterations) - .report(); + 'IsolateJson.SendAndExit_Decode${config.suffix}x$iterations', + useSendAndExit: true, + sample: config.sample, + numTasks: iterations, + ).report(); SyncJsonDecodingBenchmark( - 'IsolateJson.SyncDecode${config.suffix}x$iterations', - sample: config.sample, - iterations: iterations) - .report(); + 'IsolateJson.SyncDecode${config.suffix}x$iterations', + sample: config.sample, + iterations: iterations, + ).report(); } } } diff --git a/benchmarks/IsolateJson/dart2/IsolateJson.dart b/benchmarks/IsolateJson/dart2/IsolateJson.dart index a78b95dd62a..44981b517be 100644 --- a/benchmarks/IsolateJson/dart2/IsolateJson.dart +++ b/benchmarks/IsolateJson/dart2/IsolateJson.dart @@ -14,10 +14,12 @@ import 'package:benchmark_harness/benchmark_harness.dart' show BenchmarkBase; import 'package:meta/meta.dart'; class JsonDecodingBenchmark { - JsonDecodingBenchmark(this.name, - {@required this.sample, - @required this.numTasks, - @required this.useSendAndExit}); + JsonDecodingBenchmark( + this.name, { + @required this.sample, + @required this.numTasks, + @required this.useSendAndExit, + }); Future report() async { final stopwatch = Stopwatch()..start(); @@ -66,9 +68,12 @@ Future decodeJson(bool useSendAndExit, Uint8List encodedJson) async { stderr.writeln('worker errored out $v'); completer.completeError(true); }); - await Isolate.spawn(jsonDecodingIsolate, - JsonDecodeRequest(useSendAndExit, port.sendPort, encodedJson), - onError: workerErroredPort.sendPort, onExit: workerExitedPort.sendPort); + await Isolate.spawn( + jsonDecodingIsolate, + JsonDecodeRequest(useSendAndExit, port.sendPort, encodedJson), + onError: workerErroredPort.sendPort, + onExit: workerExitedPort.sendPort, + ); await completer.future; workerExitedPort.close(); workerErroredPort.close(); @@ -88,9 +93,11 @@ Future jsonDecodingIsolate(JsonDecodeRequest request) async { } class SyncJsonDecodingBenchmark extends BenchmarkBase { - SyncJsonDecodingBenchmark(String name, - {@required this.sample, @required this.iterations}) - : super(name); + SyncJsonDecodingBenchmark( + String name, { + @required this.sample, + @required this.iterations, + }) : super(name); @override void run() { @@ -140,22 +147,22 @@ Future main() async { for (final config in configs) { for (final iterations in [1, 4]) { await JsonDecodingBenchmark( - 'IsolateJson.Decode${config.suffix}x$iterations', - useSendAndExit: false, - sample: config.sample, - numTasks: iterations) - .report(); + 'IsolateJson.Decode${config.suffix}x$iterations', + useSendAndExit: false, + sample: config.sample, + numTasks: iterations, + ).report(); await JsonDecodingBenchmark( - 'IsolateJson.SendAndExit_Decode${config.suffix}x$iterations', - useSendAndExit: true, - sample: config.sample, - numTasks: iterations) - .report(); + 'IsolateJson.SendAndExit_Decode${config.suffix}x$iterations', + useSendAndExit: true, + sample: config.sample, + numTasks: iterations, + ).report(); SyncJsonDecodingBenchmark( - 'IsolateJson.SyncDecode${config.suffix}x$iterations', - sample: config.sample, - iterations: iterations) - .report(); + 'IsolateJson.SyncDecode${config.suffix}x$iterations', + sample: config.sample, + iterations: iterations, + ).report(); } } } diff --git a/benchmarks/IsolateRegExp/dart/IsolateRegExp.dart b/benchmarks/IsolateRegExp/dart/IsolateRegExp.dart index a139d9c69eb..b4e0610835f 100644 --- a/benchmarks/IsolateRegExp/dart/IsolateRegExp.dart +++ b/benchmarks/IsolateRegExp/dart/IsolateRegExp.dart @@ -39,8 +39,11 @@ class SendReceiveHelper { final port = ReceivePort(); inbox = StreamIterator(port); workerExitedPort = ReceivePort(); - await Isolate.spawn(isolate, port.sendPort, - onExit: workerExitedPort.sendPort); + await Isolate.spawn( + isolate, + port.sendPort, + onExit: workerExitedPort.sendPort, + ); await inbox.moveNext(); outbox = inbox.current; } @@ -88,7 +91,8 @@ Future isolate(SendPort sendPort) async { Future main() async { await SendReceiveRegExp('IsolateRegExp.MatchFast', RegExp('h?h')).report(); - await SendReceiveRegExp('IsolateRegExp.MatchSlow', - RegExp(r'(?<=\W|\b|^)(a.? b c.?) ?(\(.*\))?$')) - .report(); + await SendReceiveRegExp( + 'IsolateRegExp.MatchSlow', + RegExp(r'(?<=\W|\b|^)(a.? b c.?) ?(\(.*\))?$'), + ).report(); } diff --git a/benchmarks/IsolateSendExitLatency/dart/IsolateSendExitLatency.dart b/benchmarks/IsolateSendExitLatency/dart/IsolateSendExitLatency.dart index d3797fe7711..d198ae96d1c 100644 --- a/benchmarks/IsolateSendExitLatency/dart/IsolateSendExitLatency.dart +++ b/benchmarks/IsolateSendExitLatency/dart/IsolateSendExitLatency.dart @@ -11,13 +11,16 @@ import 'dart:isolate'; import 'latency.dart'; Future main() async { - final statsFuture = - measureEventLoopLatency(const Duration(milliseconds: 1), 4000, work: () { - // Every 1 ms we allocate some objects which may trigger GC some time. - for (int i = 0; i < 32; i++) { - List.filled(32 * 1024 ~/ 8, null); - } - }); + final statsFuture = measureEventLoopLatency( + const Duration(milliseconds: 1), + 4000, + work: () { + // Every 1 ms we allocate some objects which may trigger GC some time. + for (int i = 0; i < 32; i++) { + List.filled(32 * 1024 ~/ 8, null); + } + }, + ); final result = await compute(() { final l = []; diff --git a/benchmarks/IsolateSendExitLatency/dart/latency.dart b/benchmarks/IsolateSendExitLatency/dart/latency.dart index 7182429adb6..1efeaca63e5 100644 --- a/benchmarks/IsolateSendExitLatency/dart/latency.dart +++ b/benchmarks/IsolateSendExitLatency/dart/latency.dart @@ -13,8 +13,10 @@ import 'dart:typed_data'; /// /// Runs [numberOfTicks] times before completing with [EventLoopLatencyStats]. Future measureEventLoopLatency( - Duration tickDuration, int numberOfTicks, - {void Function()? work}) { + Duration tickDuration, + int numberOfTicks, { + void Function()? work, +}) { final completer = Completer(); final tickDurationInUs = tickDuration.inMicroseconds; @@ -74,13 +76,14 @@ class EventLoopLatencyStats { final double percentile99th; EventLoopLatencyStats( - this.minLatency, - this.avgLatency, - this.maxLatency, - this.percentile50th, - this.percentile90th, - this.percentile95th, - this.percentile99th); + this.minLatency, + this.avgLatency, + this.maxLatency, + this.percentile50th, + this.percentile90th, + this.percentile95th, + this.percentile99th, + ); void report(String name) { print('$name.Min(RunTimeRaw): $minLatency ms.'); @@ -122,12 +125,13 @@ class _TickLatencies { final percentile99th = _timestamps[99 * length ~/ 100]; return EventLoopLatencyStats( - min / 1000, - avg / 1000, - max / 1000, - percentile50th / 1000, - percentile90th / 1000, - percentile95th / 1000, - percentile99th / 1000); + min / 1000, + avg / 1000, + max / 1000, + percentile50th / 1000, + percentile90th / 1000, + percentile95th / 1000, + percentile99th / 1000, + ); } } diff --git a/benchmarks/IsolateSendExitLatency/dart2/IsolateSendExitLatency.dart b/benchmarks/IsolateSendExitLatency/dart2/IsolateSendExitLatency.dart index c165c738883..d4befa6d4dd 100644 --- a/benchmarks/IsolateSendExitLatency/dart2/IsolateSendExitLatency.dart +++ b/benchmarks/IsolateSendExitLatency/dart2/IsolateSendExitLatency.dart @@ -15,13 +15,16 @@ import 'dart:isolate'; import 'latency.dart'; main() async { - final statsFuture = - measureEventLoopLatency(const Duration(milliseconds: 1), 4000, work: () { - // Every 1 ms we allocate some objects which may trigger GC some time. - for (int i = 0; i < 32; i++) { - List.filled(32 * 1024 ~/ 8, null); - } - }); + final statsFuture = measureEventLoopLatency( + const Duration(milliseconds: 1), + 4000, + work: () { + // Every 1 ms we allocate some objects which may trigger GC some time. + for (int i = 0; i < 32; i++) { + List.filled(32 * 1024 ~/ 8, null); + } + }, + ); final result = await compute(() { final l = []; diff --git a/benchmarks/IsolateSendExitLatency/dart2/latency.dart b/benchmarks/IsolateSendExitLatency/dart2/latency.dart index 8b3352c8a8a..4435eba554f 100644 --- a/benchmarks/IsolateSendExitLatency/dart2/latency.dart +++ b/benchmarks/IsolateSendExitLatency/dart2/latency.dart @@ -16,8 +16,10 @@ import 'dart:typed_data'; /// /// Runs [numberOfTicks] times before completing with [EventLoopLatencyStats]. Future measureEventLoopLatency( - Duration tickDuration, int numberOfTicks, - {void Function() work}) { + Duration tickDuration, + int numberOfTicks, { + void Function() work, +}) { final completer = Completer(); final tickDurationInUs = tickDuration.inMicroseconds; @@ -77,13 +79,14 @@ class EventLoopLatencyStats { final double percentile99th; EventLoopLatencyStats( - this.minLatency, - this.avgLatency, - this.maxLatency, - this.percentile50th, - this.percentile90th, - this.percentile95th, - this.percentile99th); + this.minLatency, + this.avgLatency, + this.maxLatency, + this.percentile50th, + this.percentile90th, + this.percentile95th, + this.percentile99th, + ); void report(String name) { print('$name.Min(RunTimeRaw): $minLatency ms.'); @@ -125,12 +128,13 @@ class _TickLatencies { final percentile99th = _timestamps[99 * length ~/ 100]; return EventLoopLatencyStats( - min / 1000, - avg / 1000, - max / 1000, - percentile50th / 1000, - percentile90th / 1000, - percentile95th / 1000, - percentile99th / 1000); + min / 1000, + avg / 1000, + max / 1000, + percentile50th / 1000, + percentile90th / 1000, + percentile95th / 1000, + percentile99th / 1000, + ); } } diff --git a/benchmarks/IsolateSpawn/dart/IsolateSpawn.dart b/benchmarks/IsolateSpawn/dart/IsolateSpawn.dart index f00090155e5..514a5bee3e7 100644 --- a/benchmarks/IsolateSpawn/dart/IsolateSpawn.dart +++ b/benchmarks/IsolateSpawn/dart/IsolateSpawn.dart @@ -15,15 +15,17 @@ class SpawnLatency { final completerResult = Completer(); final receivePort = ReceivePort()..listen(completerResult.complete); final isolateExitedCompleter = Completer(); - final onExitReceivePort = ReceivePort() - ..listen((_) { - isolateExitedCompleter.complete(DateTime.now()); - }); + final onExitReceivePort = + ReceivePort()..listen((_) { + isolateExitedCompleter.complete(DateTime.now()); + }); final beforeSpawn = DateTime.now(); await Isolate.spawn( - isolateCompiler, StartMessageLatency(receivePort.sendPort, beforeSpawn), - onExit: onExitReceivePort.sendPort, - onError: onExitReceivePort.sendPort); + isolateCompiler, + StartMessageLatency(receivePort.sendPort, beforeSpawn), + onExit: onExitReceivePort.sendPort, + onError: onExitReceivePort.sendPort, + ); final afterSpawn = DateTime.now(); final ResultMessageLatency result = await completerResult.future; @@ -42,8 +44,9 @@ class SpawnLatency { final watch = Stopwatch()..start(); final Metric toAfterIsolateSpawnUs = LatencyMetric('${name}ToAfterSpawn'); final Metric toStartRunningCodeUs = LatencyMetric('${name}ToStartRunning'); - final Metric toFinishRunningCodeUs = - LatencyMetric('${name}ToFinishRunning'); + final Metric toFinishRunningCodeUs = LatencyMetric( + '${name}ToFinishRunning', + ); final Metric toExitUs = LatencyMetric('${name}ToExit'); while (watch.elapsedMicroseconds < minimumMicros) { final result = await run(); @@ -52,8 +55,12 @@ class SpawnLatency { toFinishRunningCodeUs.add(result.timeToFinishRunningCodeUs); toExitUs.add(result.timeToExitUs); } - return AggregatedResultMessageLatency(toAfterIsolateSpawnUs, - toStartRunningCodeUs, toFinishRunningCodeUs, toExitUs); + return AggregatedResultMessageLatency( + toAfterIsolateSpawnUs, + toStartRunningCodeUs, + toFinishRunningCodeUs, + toExitUs, + ); } Future measure() async { @@ -86,7 +93,8 @@ class Metric { double _rms() => sqrt(sumOfSquares / count); @override - String toString() => '$prefix): ${_average()}$suffix\n' + String toString() => + '$prefix): ${_average()}$suffix\n' '${prefix}Max): $max$suffix\n' '${prefix}RMS): ${_rms()}$suffix'; @@ -110,9 +118,10 @@ class StartMessageLatency { } class ResultMessageLatency { - ResultMessageLatency( - {required this.timeToStartRunningCodeUs, - required this.timeToFinishRunningCodeUs}); + ResultMessageLatency({ + required this.timeToStartRunningCodeUs, + required this.timeToFinishRunningCodeUs, + }); final int timeToStartRunningCodeUs; final int timeToFinishRunningCodeUs; @@ -144,18 +153,23 @@ $toExitUs'''; Future isolateCompiler(StartMessageLatency start) async { final timeRunningCodeUs = DateTime.now(); await runZoned( - () => gen_kernel.compile([ - 'benchmarks/IsolateSpawn/dart/helloworld.dart', - 'benchmarks/IsolateSpawn/dart/helloworld.dart.dill', - ]), - zoneSpecification: ZoneSpecification( - print: (Zone self, ZoneDelegate parent, Zone zone, String line) {})); + () => gen_kernel.compile([ + 'benchmarks/IsolateSpawn/dart/helloworld.dart', + 'benchmarks/IsolateSpawn/dart/helloworld.dart.dill', + ]), + zoneSpecification: ZoneSpecification( + print: (Zone self, ZoneDelegate parent, Zone zone, String line) {}, + ), + ); final timeFinishRunningCodeUs = DateTime.now(); - start.sendPort.send(ResultMessageLatency( + start.sendPort.send( + ResultMessageLatency( timeToStartRunningCodeUs: timeRunningCodeUs.difference(start.spawned).inMicroseconds, timeToFinishRunningCodeUs: - timeFinishRunningCodeUs.difference(start.spawned).inMicroseconds)); + timeFinishRunningCodeUs.difference(start.spawned).inMicroseconds, + ), + ); } Future main() async { diff --git a/benchmarks/IsolateSpawn/dart2/IsolateSpawn.dart b/benchmarks/IsolateSpawn/dart2/IsolateSpawn.dart index 96ebfc422af..d8391cada0f 100644 --- a/benchmarks/IsolateSpawn/dart2/IsolateSpawn.dart +++ b/benchmarks/IsolateSpawn/dart2/IsolateSpawn.dart @@ -19,15 +19,17 @@ class SpawnLatency { final completerResult = Completer(); final receivePort = ReceivePort()..listen(completerResult.complete); final isolateExitedCompleter = Completer(); - final onExitReceivePort = ReceivePort() - ..listen((_) { - isolateExitedCompleter.complete(DateTime.now()); - }); + final onExitReceivePort = + ReceivePort()..listen((_) { + isolateExitedCompleter.complete(DateTime.now()); + }); final beforeSpawn = DateTime.now(); await Isolate.spawn( - isolateCompiler, StartMessageLatency(receivePort.sendPort, beforeSpawn), - onExit: onExitReceivePort.sendPort, - onError: onExitReceivePort.sendPort); + isolateCompiler, + StartMessageLatency(receivePort.sendPort, beforeSpawn), + onExit: onExitReceivePort.sendPort, + onError: onExitReceivePort.sendPort, + ); final afterSpawn = DateTime.now(); final ResultMessageLatency result = await completerResult.future; @@ -46,8 +48,9 @@ class SpawnLatency { final watch = Stopwatch()..start(); final Metric toAfterIsolateSpawnUs = LatencyMetric('${name}ToAfterSpawn'); final Metric toStartRunningCodeUs = LatencyMetric('${name}ToStartRunning'); - final Metric toFinishRunningCodeUs = - LatencyMetric('${name}ToFinishRunning'); + final Metric toFinishRunningCodeUs = LatencyMetric( + '${name}ToFinishRunning', + ); final Metric toExitUs = LatencyMetric('${name}ToExit'); while (watch.elapsedMicroseconds < minimumMicros) { final result = await run(); @@ -56,8 +59,12 @@ class SpawnLatency { toFinishRunningCodeUs.add(result.timeToFinishRunningCodeUs); toExitUs.add(result.timeToExitUs); } - return AggregatedResultMessageLatency(toAfterIsolateSpawnUs, - toStartRunningCodeUs, toFinishRunningCodeUs, toExitUs); + return AggregatedResultMessageLatency( + toAfterIsolateSpawnUs, + toStartRunningCodeUs, + toFinishRunningCodeUs, + toExitUs, + ); } Future measure() async { @@ -90,7 +97,8 @@ class Metric { double _rms() => sqrt(sumOfSquares / count); @override - String toString() => '$prefix): ${_average()}$suffix\n' + String toString() => + '$prefix): ${_average()}$suffix\n' '${prefix}Max): $max$suffix\n' '${prefix}RMS): ${_rms()}$suffix'; @@ -114,10 +122,11 @@ class StartMessageLatency { } class ResultMessageLatency { - ResultMessageLatency( - {this.timeToStartRunningCodeUs, - this.timeToFinishRunningCodeUs, - this.deltaHeap}); + ResultMessageLatency({ + this.timeToStartRunningCodeUs, + this.timeToFinishRunningCodeUs, + this.deltaHeap, + }); final int timeToStartRunningCodeUs; final int timeToFinishRunningCodeUs; @@ -150,18 +159,23 @@ $toExitUs'''; Future isolateCompiler(StartMessageLatency start) async { final timeRunningCodeUs = DateTime.now(); await runZoned( - () => dart2js_main.internalMain([ - 'benchmarks/IsolateSpawn/dart/helloworld.dart', - '--libraries-spec=sdk/lib/libraries.json' - ]), - zoneSpecification: ZoneSpecification( - print: (Zone self, ZoneDelegate parent, Zone zone, String line) {})); + () => dart2js_main.internalMain([ + 'benchmarks/IsolateSpawn/dart/helloworld.dart', + '--libraries-spec=sdk/lib/libraries.json', + ]), + zoneSpecification: ZoneSpecification( + print: (Zone self, ZoneDelegate parent, Zone zone, String line) {}, + ), + ); final timeFinishRunningCodeUs = DateTime.now(); - start.sendPort.send(ResultMessageLatency( + start.sendPort.send( + ResultMessageLatency( timeToStartRunningCodeUs: timeRunningCodeUs.difference(start.spawned).inMicroseconds, timeToFinishRunningCodeUs: - timeFinishRunningCodeUs.difference(start.spawned).inMicroseconds)); + timeFinishRunningCodeUs.difference(start.spawned).inMicroseconds, + ), + ); } Future main() async { diff --git a/benchmarks/IsolateSpawnMemory/dart/IsolateSpawnMemory.dart b/benchmarks/IsolateSpawnMemory/dart/IsolateSpawnMemory.dart index a6cfe56a6ac..4be033dd5cf 100644 --- a/benchmarks/IsolateSpawnMemory/dart/IsolateSpawnMemory.dart +++ b/benchmarks/IsolateSpawnMemory/dart/IsolateSpawnMemory.dart @@ -17,7 +17,11 @@ const String compilerIsolateName = 'isolate-compiler'; class Result { const Result( - this.rssOnStart, this.rssOnEnd, this.heapOnStart, this.heapOnEnd); + this.rssOnStart, + this.rssOnEnd, + this.heapOnStart, + this.heapOnEnd, + ); final int rssOnStart; final int rssOnEnd; @@ -53,8 +57,11 @@ class SpawnMemory { for (int i = 0; i < numberOfBenchmarks; i++) { final receivePort = ReceivePort(); final startMessage = StartMessage(wsUri, receivePort.sendPort); - await Isolate.spawn(isolateCompiler, startMessage, - debugName: compilerIsolateName); + await Isolate.spawn( + isolateCompiler, + startMessage, + debugName: compilerIsolateName, + ); final iterator = StreamIterator(receivePort); if (!await iterator.moveNext()) throw 'failed'; @@ -117,12 +124,14 @@ Future isolateCompiler(StartMessage startMessage) async { await iterator.moveNext(); await runZoned( - () => gen_kernel.compile([ - 'benchmarks/IsolateSpawn/dart/helloworld.dart', - 'benchmarks/IsolateSpawn/dart/helloworld.dart.dill', - ]), - zoneSpecification: ZoneSpecification( - print: (Zone self, ZoneDelegate parent, Zone zone, String line) {})); + () => gen_kernel.compile([ + 'benchmarks/IsolateSpawn/dart/helloworld.dart', + 'benchmarks/IsolateSpawn/dart/helloworld.dart.dill', + ]), + zoneSpecification: ZoneSpecification( + print: (Zone self, ZoneDelegate parent, Zone zone, String line) {}, + ), + ); // Let main isolate know we're done. startMessage.sendPort.send('done'); diff --git a/benchmarks/IsolateSpawnMemory/dart2/IsolateSpawnMemory.dart b/benchmarks/IsolateSpawnMemory/dart2/IsolateSpawnMemory.dart index 28fee38b62d..2cf8b633767 100644 --- a/benchmarks/IsolateSpawnMemory/dart2/IsolateSpawnMemory.dart +++ b/benchmarks/IsolateSpawnMemory/dart2/IsolateSpawnMemory.dart @@ -18,7 +18,11 @@ const String compilerIsolateName = 'isolate-compiler'; class Result { const Result( - this.rssOnStart, this.rssOnEnd, this.heapOnStart, this.heapOnEnd); + this.rssOnStart, + this.rssOnEnd, + this.heapOnStart, + this.heapOnEnd, + ); final int rssOnStart; final int rssOnEnd; @@ -54,8 +58,11 @@ class SpawnMemory { for (int i = 0; i < numberOfBenchmarks; i++) { final receivePort = ReceivePort(); final startMessage = StartMessage(wsUri, receivePort.sendPort); - await Isolate.spawn(isolateCompiler, startMessage, - debugName: compilerIsolateName); + await Isolate.spawn( + isolateCompiler, + startMessage, + debugName: compilerIsolateName, + ); final iterator = StreamIterator(receivePort); if (!await iterator.moveNext()) throw 'failed'; @@ -118,12 +125,14 @@ Future isolateCompiler(StartMessage startMessage) async { await iterator.moveNext(); await runZoned( - () => dart2js_main.internalMain([ - 'benchmarks/IsolateSpawnMemory/dart/helloworld.dart', - '--libraries-spec=sdk/lib/libraries.json' - ]), - zoneSpecification: ZoneSpecification( - print: (Zone self, ZoneDelegate parent, Zone zone, String line) {})); + () => dart2js_main.internalMain([ + 'benchmarks/IsolateSpawnMemory/dart/helloworld.dart', + '--libraries-spec=sdk/lib/libraries.json', + ]), + zoneSpecification: ZoneSpecification( + print: (Zone self, ZoneDelegate parent, Zone zone, String line) {}, + ), + ); // Let main isolate know we're done. startMessage.sendPort.send('done'); diff --git a/benchmarks/Iterators/dart/Iterators.dart b/benchmarks/Iterators/dart/Iterators.dart index 83621da50c5..6bcc5aeca0b 100644 --- a/benchmarks/Iterators/dart/Iterators.dart +++ b/benchmarks/Iterators/dart/Iterators.dart @@ -128,7 +128,7 @@ abstract class Benchmark extends BenchmarkBase { final int size; bool selected = false; Benchmark._(String name, this.size) - : super('Iterators.$name.$size', emitter: Emitter()); + : super('Iterators.$name.$size', emitter: Emitter()); factory Benchmark(String name, int size, Iterable Function(int) generate) = PolyBenchmark; @@ -137,8 +137,8 @@ abstract class Benchmark extends BenchmarkBase { abstract class MonoBenchmark extends Benchmark { final int _repeats; MonoBenchmark(String name, int size) - : _repeats = size == 0 ? targetSize : targetSize ~/ size, - super._('mono.$name', size); + : _repeats = size == 0 ? targetSize : targetSize ~/ size, + super._('mono.$name', size); @override void run() { @@ -155,7 +155,7 @@ class PolyBenchmark extends Benchmark { final List inputs = []; PolyBenchmark(String name, int size, this.generate) - : super._('poly.$name', size); + : super._('poly.$name', size); @override void setup() { @@ -304,8 +304,8 @@ class BenchmarkNothing extends MonoBenchmark { class BenchmarkCodeUnits extends MonoBenchmark { BenchmarkCodeUnits(int size) - : string = generateString(size), - super('CodeUnits', size); + : string = generateString(size), + super('CodeUnits', size); final String string; @@ -319,8 +319,8 @@ class BenchmarkCodeUnits extends MonoBenchmark { class BenchmarkListIntGrowable extends MonoBenchmark { BenchmarkListIntGrowable(int size) - : _list = List.generate(size, (i) => i), - super('List.int.growable', size); + : _list = List.generate(size, (i) => i), + super('List.int.growable', size); final List _list; @@ -341,9 +341,9 @@ class BenchmarkListIntSystem1 extends MonoBenchmark { // Ideally some combination of the class hierarchy or compiler tricks would // ensure there is little cost of having this gentle polymorphism. BenchmarkListIntSystem1(int size) - : _list1 = List.generate(size, (i) => i), - _list2 = generateConstListOfInt(size), - super('List.int.growable.and.const', size); + : _list1 = List.generate(size, (i) => i), + _list2 = generateConstListOfInt(size), + super('List.int.growable.and.const', size); final List _list1; final List _list2; @@ -368,9 +368,9 @@ class BenchmarkListIntSystem2 extends MonoBenchmark { // Ideally some combination of the class hierarchy or compiler tricks would // ensure there is little cost of having this gentle polymorphism. BenchmarkListIntSystem2(int size) - : _list1 = List.generate(size, (i) => i, growable: false), - _list2 = generateConstListOfInt(size), - super('List.int.fixed.and.const', size); + : _list1 = List.generate(size, (i) => i, growable: false), + _list2 = generateConstListOfInt(size), + super('List.int.fixed.and.const', size); final List _list1; final List _list2; @@ -458,12 +458,13 @@ List>> generateThingList(int n) { } Map>, Thing>> generateThingMap( - int n) { + int n, +) { return Map.fromIterables(generateThingList(n), generateThingList(n)); } Map>, Thing>> - generateThingHashMap(int n) { +generateThingHashMap(int n) { return HashMap.fromIterables(generateThingList(n), generateThingList(n)); } @@ -484,10 +485,12 @@ Map generateIdentityMapIntInt(int n) { void pollute() { // This iterable reads `sink` mid-loop, making it infeasible for the compiler // to move the write to `sink` out of the loop. - sinkAll(UpTo(100).map((i) { - if (i > 0 && sink != i - 1) throw StateError('sink'); - return i; - })); + sinkAll( + UpTo(100).map((i) { + if (i > 0 && sink != i - 1) throw StateError('sink'); + return i; + }), + ); // TODO(sra): Do we need to add anything here? There are a lot of benchmarks, // so that is probably sufficient to make the necessary places polymorphic. @@ -549,12 +552,21 @@ void main(List commandLineArguments) { BenchmarkListIntGrowable(size), BenchmarkListIntSystem1(size), BenchmarkListIntSystem2(size), - Benchmark('List.int.growable', size, - (n) => List.of(UpTo(n), growable: true)), - Benchmark('List.int.fixed', size, - (n) => List.of(UpTo(n), growable: false)), - Benchmark('List.int.unmodifiable', size, - (n) => List.unmodifiable(UpTo(n))), + Benchmark( + 'List.int.growable', + size, + (n) => List.of(UpTo(n), growable: true), + ), + Benchmark( + 'List.int.fixed', + size, + (n) => List.of(UpTo(n), growable: false), + ), + Benchmark( + 'List.int.unmodifiable', + size, + (n) => List.unmodifiable(UpTo(n)), + ), // --- Benchmark('List.Hard.growable', size, generateThingList), // --- @@ -566,33 +578,63 @@ void main(List commandLineArguments) { Benchmark('Map.int.values', size, (n) => generateMapIntInt(n).values), Benchmark('Map.int.entries', size, (n) => generateMapIntInt(n).entries), // --- - Benchmark('Map.identity.int.keys', size, - (n) => generateIdentityMapIntInt(n).keys), - Benchmark('Map.identity.int.values', size, - (n) => generateIdentityMapIntInt(n).values), - Benchmark('Map.identity.int.entries', size, - (n) => generateIdentityMapIntInt(n).entries), + Benchmark( + 'Map.identity.int.keys', + size, + (n) => generateIdentityMapIntInt(n).keys, + ), + Benchmark( + 'Map.identity.int.values', + size, + (n) => generateIdentityMapIntInt(n).values, + ), + Benchmark( + 'Map.identity.int.entries', + size, + (n) => generateIdentityMapIntInt(n).entries, + ), // --- Benchmark( - 'const.Map.int.keys', size, (n) => generateConstMapIntInt(n).keys), - Benchmark('const.Map.int.values', size, - (n) => generateConstMapIntInt(n).values), - Benchmark('const.Map.int.entries', size, - (n) => generateConstMapIntInt(n).entries), + 'const.Map.int.keys', + size, + (n) => generateConstMapIntInt(n).keys, + ), + Benchmark( + 'const.Map.int.values', + size, + (n) => generateConstMapIntInt(n).values, + ), + Benchmark( + 'const.Map.int.entries', + size, + (n) => generateConstMapIntInt(n).entries, + ), // --- Benchmark('Map.Hard.keys', size, (n) => generateThingMap(n).keys), Benchmark('Map.Hard.values', size, (n) => generateThingMap(n).values), // --- - Benchmark('HashMap.int.keys', size, - (n) => HashMap.fromIterables(UpTo(n), UpTo(n)).keys), - Benchmark('HashMap.int.values', size, - (n) => HashMap.fromIterables(UpTo(n), UpTo(n)).values), - Benchmark('HashMap.int.entries', size, - (n) => HashMap.fromIterables(UpTo(n), UpTo(n)).entries), + Benchmark( + 'HashMap.int.keys', + size, + (n) => HashMap.fromIterables(UpTo(n), UpTo(n)).keys, + ), + Benchmark( + 'HashMap.int.values', + size, + (n) => HashMap.fromIterables(UpTo(n), UpTo(n)).values, + ), + Benchmark( + 'HashMap.int.entries', + size, + (n) => HashMap.fromIterables(UpTo(n), UpTo(n)).entries, + ), // --- Benchmark('HashMap.Hard.keys', size, (n) => generateThingHashMap(n).keys), Benchmark( - 'HashMap.Hard.values', size, (n) => generateThingHashMap(n).values), + 'HashMap.Hard.values', + size, + (n) => generateThingHashMap(n).values, + ), ]; } diff --git a/benchmarks/Iterators/dart/data.dart b/benchmarks/Iterators/dart/data.dart index f59c26f8d7c..a6d5214dfbf 100644 --- a/benchmarks/Iterators/dart/data.dart +++ b/benchmarks/Iterators/dart/data.dart @@ -21,7 +21,7 @@ const Map> constMapIntIntTable = { 0: constMapIntInt0, 1: constMapIntInt1, 2: constMapIntInt2, - 100: constMapIntInt100 + 100: constMapIntInt100, }; const Map constMapIntInt0 = {}; @@ -127,14 +127,14 @@ const Map constMapIntInt100 = { 96: 96, 97: 97, 98: 98, - 99: 99 + 99: 99, }; const Map> constSetOfIntTable = { 0: constSetOfInt0, 1: constSetOfInt1, 2: constSetOfInt2, - 100: constSetOfInt100 + 100: constSetOfInt100, }; const Set constSetOfInt0 = {}; @@ -150,14 +150,14 @@ const Set constSetOfInt100 = { ...{60, 61, 62, 63, 64, 65, 66, 67, 68, 69}, ...{70, 71, 72, 73, 74, 75, 76, 77, 78, 79}, ...{80, 81, 82, 83, 84, 85, 86, 87, 88, 89}, - ...{90, 91, 92, 93, 94, 95, 96, 97, 98, 99} + ...{90, 91, 92, 93, 94, 95, 96, 97, 98, 99}, }; const Map> constListOfIntTable = { 0: constListOfInt0, 1: constListOfInt1, 2: constListOfInt2, - 100: constListOfInt100 + 100: constListOfInt100, }; const List constListOfInt0 = []; @@ -173,5 +173,5 @@ const List constListOfInt100 = [ ...[60, 61, 62, 63, 64, 65, 66, 67, 68, 69], ...[70, 71, 72, 73, 74, 75, 76, 77, 78, 79], ...[80, 81, 82, 83, 84, 85, 86, 87, 88, 89], - ...[90, 91, 92, 93, 94, 95, 96, 97, 98, 99] + ...[90, 91, 92, 93, 94, 95, 96, 97, 98, 99], ]; diff --git a/benchmarks/ListCopy/dart/ListCopy.dart b/benchmarks/ListCopy/dart/ListCopy.dart index 86a3d5c433b..ecf8d058c32 100644 --- a/benchmarks/ListCopy/dart/ListCopy.dart +++ b/benchmarks/ListCopy/dart/ListCopy.dart @@ -31,7 +31,7 @@ class Benchmark extends BenchmarkBase { final List> inputs = []; Benchmark(String name, this.length, this.copy) - : super('ListCopy.$name.$length'); + : super('ListCopy.$name.$length'); @override void setup() { @@ -57,8 +57,10 @@ class Benchmark extends BenchmarkBase { while (totalLength < elements) { final variants = makeVariants(); inputs.addAll(variants); - totalLength += - variants.fold(0, (sum, iterable) => sum + iterable.length); + totalLength += variants.fold( + 0, + (sum, iterable) => sum + iterable.length, + ); } // Sanity checks. @@ -97,52 +99,52 @@ Iterable input = const []; var output; List makeBenchmarks(int length) => [ - Benchmark('toList', length, () { - output = input.toList(); - }), - Benchmark('toList.fixed', length, () { - output = input.toList(growable: false); - }), - Benchmark('List.of', length, () { - output = List.of(input); - }), - Benchmark('List.of.fixed', length, () { - output = List.of(input, growable: false); - }), - Benchmark('List.num.from', length, () { - output = List.from(input); - }), - Benchmark('List.int.from', length, () { - output = List.from(input); - }), - Benchmark('List.num.from.fixed', length, () { - output = List.from(input, growable: false); - }), - Benchmark('List.int.from.fixed', length, () { - output = List.from(input, growable: false); - }), - Benchmark('List.num.unmodifiable', length, () { - output = List.unmodifiable(input); - }), - Benchmark('List.int.unmodifiable', length, () { - output = List.unmodifiable(input); - }), - Benchmark('spread.num', length, () { - output = [...input]; - }), - Benchmark('spread.int', length, () { - output = [...input as dynamic]; - }), - Benchmark('spread.int.cast', length, () { - output = [...input.cast()]; - }), - Benchmark('spread.int.map', length, () { - output = [...input.map((x) => x as int)]; - }), - Benchmark('for.int', length, () { - output = [for (var n in input) n as int]; - }), - ]; + Benchmark('toList', length, () { + output = input.toList(); + }), + Benchmark('toList.fixed', length, () { + output = input.toList(growable: false); + }), + Benchmark('List.of', length, () { + output = List.of(input); + }), + Benchmark('List.of.fixed', length, () { + output = List.of(input, growable: false); + }), + Benchmark('List.num.from', length, () { + output = List.from(input); + }), + Benchmark('List.int.from', length, () { + output = List.from(input); + }), + Benchmark('List.num.from.fixed', length, () { + output = List.from(input, growable: false); + }), + Benchmark('List.int.from.fixed', length, () { + output = List.from(input, growable: false); + }), + Benchmark('List.num.unmodifiable', length, () { + output = List.unmodifiable(input); + }), + Benchmark('List.int.unmodifiable', length, () { + output = List.unmodifiable(input); + }), + Benchmark('spread.num', length, () { + output = [...input]; + }), + Benchmark('spread.int', length, () { + output = [...input as dynamic]; + }), + Benchmark('spread.int.cast', length, () { + output = [...input.cast()]; + }), + Benchmark('spread.int.map', length, () { + output = [...input.map((x) => x as int)]; + }), + Benchmark('for.int', length, () { + output = [for (var n in input) n as int]; + }), +]; void main() { final benchmarks = [...makeBenchmarks(2), ...makeBenchmarks(100)]; diff --git a/benchmarks/ListCopy/dart2/ListCopy.dart b/benchmarks/ListCopy/dart2/ListCopy.dart index 34da1ebcd5a..f05c5dd7e25 100644 --- a/benchmarks/ListCopy/dart2/ListCopy.dart +++ b/benchmarks/ListCopy/dart2/ListCopy.dart @@ -33,7 +33,7 @@ class Benchmark extends BenchmarkBase { final List> inputs = []; Benchmark(String name, this.length, this.copy) - : super('ListCopy.$name.$length'); + : super('ListCopy.$name.$length'); @override void setup() { @@ -59,8 +59,10 @@ class Benchmark extends BenchmarkBase { while (totalLength < elements) { final variants = makeVariants(); inputs.addAll(variants); - totalLength += - variants.fold(0, (sum, iterable) => sum + iterable.length); + totalLength += variants.fold( + 0, + (sum, iterable) => sum + iterable.length, + ); } // Sanity checks. @@ -99,52 +101,52 @@ Iterable input = const []; var output; List makeBenchmarks(int length) => [ - Benchmark('toList', length, () { - output = input.toList(); - }), - Benchmark('toList.fixed', length, () { - output = input.toList(growable: false); - }), - Benchmark('List.of', length, () { - output = List.of(input); - }), - Benchmark('List.of.fixed', length, () { - output = List.of(input, growable: false); - }), - Benchmark('List.num.from', length, () { - output = List.from(input); - }), - Benchmark('List.int.from', length, () { - output = List.from(input); - }), - Benchmark('List.num.from.fixed', length, () { - output = List.from(input, growable: false); - }), - Benchmark('List.int.from.fixed', length, () { - output = List.from(input, growable: false); - }), - Benchmark('List.num.unmodifiable', length, () { - output = List.unmodifiable(input); - }), - Benchmark('List.int.unmodifiable', length, () { - output = List.unmodifiable(input); - }), - Benchmark('spread.num', length, () { - output = [...input]; - }), - Benchmark('spread.int', length, () { - output = [...input]; - }), - Benchmark('spread.int.cast', length, () { - output = [...input.cast()]; - }), - Benchmark('spread.int.map', length, () { - output = [...input.map((x) => x as int)]; - }), - Benchmark('for.int', length, () { - output = [for (var n in input) n as int]; - }), - ]; + Benchmark('toList', length, () { + output = input.toList(); + }), + Benchmark('toList.fixed', length, () { + output = input.toList(growable: false); + }), + Benchmark('List.of', length, () { + output = List.of(input); + }), + Benchmark('List.of.fixed', length, () { + output = List.of(input, growable: false); + }), + Benchmark('List.num.from', length, () { + output = List.from(input); + }), + Benchmark('List.int.from', length, () { + output = List.from(input); + }), + Benchmark('List.num.from.fixed', length, () { + output = List.from(input, growable: false); + }), + Benchmark('List.int.from.fixed', length, () { + output = List.from(input, growable: false); + }), + Benchmark('List.num.unmodifiable', length, () { + output = List.unmodifiable(input); + }), + Benchmark('List.int.unmodifiable', length, () { + output = List.unmodifiable(input); + }), + Benchmark('spread.num', length, () { + output = [...input]; + }), + Benchmark('spread.int', length, () { + output = [...input]; + }), + Benchmark('spread.int.cast', length, () { + output = [...input.cast()]; + }), + Benchmark('spread.int.map', length, () { + output = [...input.map((x) => x as int)]; + }), + Benchmark('for.int', length, () { + output = [for (var n in input) n as int]; + }), +]; void main() { final benchmarks = [...makeBenchmarks(2), ...makeBenchmarks(100)]; diff --git a/benchmarks/LongStringCompare/dart/LongStringCompare.dart b/benchmarks/LongStringCompare/dart/LongStringCompare.dart index 6d5aff26713..e7544f05668 100644 --- a/benchmarks/LongStringCompare/dart/LongStringCompare.dart +++ b/benchmarks/LongStringCompare/dart/LongStringCompare.dart @@ -20,7 +20,7 @@ class LongStringCompare extends BenchmarkBase { } LongStringCompare(int lengthPower, this.reps) - : super('LongStringCompare.${1 << lengthPower}.${reps}reps') { + : super('LongStringCompare.${1 << lengthPower}.${reps}reps') { final single = generateLongString(lengthPower); s.add(single + '.' + single); s.add(single + '!' + single); diff --git a/benchmarks/MD5/dart/md5.dart b/benchmarks/MD5/dart/md5.dart index 718534fb9d0..c3313565c15 100644 --- a/benchmarks/MD5/dart/md5.dart +++ b/benchmarks/MD5/dart/md5.dart @@ -13,8 +13,8 @@ class MD5Bench extends BenchmarkBase { List data; MD5Bench() - : data = List.generate(size, (i) => i % 256, growable: false), - super('MD5'); + : data = List.generate(size, (i) => i % 256, growable: false), + super('MD5'); @override void run() { diff --git a/benchmarks/MapCopy/dart/MapCopy.dart b/benchmarks/MapCopy/dart/MapCopy.dart index 2009c80b636..f5c68ab01fd 100644 --- a/benchmarks/MapCopy/dart/MapCopy.dart +++ b/benchmarks/MapCopy/dart/MapCopy.dart @@ -52,8 +52,10 @@ abstract class Benchmark extends BenchmarkBase { final List> inputs = []; Benchmark(this.targetKind, this.methodKind, this.sourceKind, this.length) - : super('MapCopy.$targetKind.${_keyKind(K)}.$methodKind.$sourceKind' - '.$length'); + : super( + 'MapCopy.$targetKind.${_keyKind(K)}.$methodKind.$sourceKind' + '.$length', + ); static String _keyKind(Type type) { if (type == String) return 'String'; @@ -149,7 +151,7 @@ class BaselineBenchmark extends Benchmark { class MapOfBenchmark extends Benchmark { MapOfBenchmark(String sourceKind, int length) - : super('Map', 'of', sourceKind, length); + : super('Map', 'of', sourceKind, length); @override void copy() { @@ -159,7 +161,7 @@ class MapOfBenchmark extends Benchmark { class HashMapOfBenchmark extends Benchmark { HashMapOfBenchmark(String sourceKind, int length) - : super('HashMap', 'of', sourceKind, length); + : super('HashMap', 'of', sourceKind, length); @override void copy() { @@ -169,7 +171,7 @@ class HashMapOfBenchmark extends Benchmark { class MapCopyOfBenchmark extends Benchmark { MapCopyOfBenchmark(String sourceKind, int length) - : super('Map', 'copyOf', sourceKind, length); + : super('Map', 'copyOf', sourceKind, length); @override void copy() { @@ -183,7 +185,7 @@ class MapCopyOfBenchmark extends Benchmark { class HashMapCopyOfBenchmark extends Benchmark { HashMapCopyOfBenchmark(String sourceKind, int length) - : super('HashMap', 'copyOf', sourceKind, length); + : super('HashMap', 'copyOf', sourceKind, length); @override void copy() { @@ -197,7 +199,7 @@ class HashMapCopyOfBenchmark extends Benchmark { class MapFromEntriesBenchmark extends Benchmark { MapFromEntriesBenchmark(String sourceKind, int length) - : super('Map', 'fromEntries', sourceKind, length); + : super('Map', 'fromEntries', sourceKind, length); @override void copy() { @@ -207,7 +209,7 @@ class MapFromEntriesBenchmark extends Benchmark { class HashMapFromEntriesBenchmark extends Benchmark { HashMapFromEntriesBenchmark(String sourceKind, int length) - : super('HashMap', 'fromEntries', sourceKind, length); + : super('HashMap', 'fromEntries', sourceKind, length); @override void copy() { @@ -222,12 +224,14 @@ void pollute() { final Map m2 = HashMap.of(m1); final Map m3 = Map.of({1: 66}); final Map m4 = HashMap.of({1: 66}); - final Map m5 = Map.identity() - ..[Thing()] = 1 - ..[Thing()] = 2; - final Map m6 = HashMap.identity() - ..[Thing()] = 1 - ..[Thing()] = 2; + final Map m5 = + Map.identity() + ..[Thing()] = 1 + ..[Thing()] = 2; + final Map m6 = + HashMap.identity() + ..[Thing()] = 1 + ..[Thing()] = 2; final Map m7 = UnmodifiableMapView(m1); final Map m8 = UnmodifiableMapView(m2); final Map m9 = UnmodifiableMapView(m3); diff --git a/benchmarks/MapLookup/dart/maps.dart b/benchmarks/MapLookup/dart/maps.dart index 0817b178146..b71e6d9d910 100644 --- a/benchmarks/MapLookup/dart/maps.dart +++ b/benchmarks/MapLookup/dart/maps.dart @@ -2,13 +2,9 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -const const1 = { - '0': '1', -}; +const const1 = {'0': '1'}; -final final1 = { - '0': '1', -}; +final final1 = {'0': '1'}; const const5 = { '0': '1', diff --git a/benchmarks/MapLookup/dart2/maps.dart b/benchmarks/MapLookup/dart2/maps.dart index 0817b178146..b71e6d9d910 100644 --- a/benchmarks/MapLookup/dart2/maps.dart +++ b/benchmarks/MapLookup/dart2/maps.dart @@ -2,13 +2,9 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -const const1 = { - '0': '1', -}; +const const1 = {'0': '1'}; -final final1 = { - '0': '1', -}; +final final1 = {'0': '1'}; const const5 = { '0': '1', diff --git a/benchmarks/MapLookup/generate_maps.dart b/benchmarks/MapLookup/generate_maps.dart index 9086cd03386..23b2798d8c4 100644 --- a/benchmarks/MapLookup/generate_maps.dart +++ b/benchmarks/MapLookup/generate_maps.dart @@ -30,8 +30,12 @@ void main() { } } -void generateMap(StringBuffer buffer, String name, int mapSize, - {bool isConst = true}) { +void generateMap( + StringBuffer buffer, + String name, + int mapSize, { + bool isConst = true, +}) { final constOrFinal = isConst ? 'const' : 'final'; buffer.write('$constOrFinal $name = {'); for (int i = 0; i < mapSize; i++) { diff --git a/benchmarks/MemoryCopy/dart/MemoryCopy.dart b/benchmarks/MemoryCopy/dart/MemoryCopy.dart index c55520b10a9..66af19c2a7e 100644 --- a/benchmarks/MemoryCopy/dart/MemoryCopy.dart +++ b/benchmarks/MemoryCopy/dart/MemoryCopy.dart @@ -13,21 +13,40 @@ import 'package:ffi/ffi.dart'; const maxSizeInBytes = 10 * 1024 * 1024; -final argParser = ArgParser() - ..addMultiOption('length', - abbr: 'l', - help: 'Byte length to benchmark', - valueHelp: 'INT', - defaultsTo: const []) - ..addFlag('mebibytes-per-second', - abbr: 'm', help: 'Show MiB/s', defaultsTo: false) - ..addFlag('nanoseconds-per-byte', - abbr: 'n', help: 'Show ns/byte', defaultsTo: false) - ..addFlag('bytes-per-second', - abbr: 'b', help: 'Show byte/s', defaultsTo: true) - ..addFlag('verbose', abbr: 'v', help: 'Verbose output', defaultsTo: false) - ..addFlag('aligned', - abbr: 'a', help: 'Align results on initial numbers', defaultsTo: false); +final argParser = + ArgParser() + ..addMultiOption( + 'length', + abbr: 'l', + help: 'Byte length to benchmark', + valueHelp: 'INT', + defaultsTo: const [], + ) + ..addFlag( + 'mebibytes-per-second', + abbr: 'm', + help: 'Show MiB/s', + defaultsTo: false, + ) + ..addFlag( + 'nanoseconds-per-byte', + abbr: 'n', + help: 'Show ns/byte', + defaultsTo: false, + ) + ..addFlag( + 'bytes-per-second', + abbr: 'b', + help: 'Show byte/s', + defaultsTo: true, + ) + ..addFlag('verbose', abbr: 'v', help: 'Verbose output', defaultsTo: false) + ..addFlag( + 'aligned', + abbr: 'a', + help: 'Align results on initial numbers', + defaultsTo: false, + ); class Emitter { final bool bytesPerSecond; @@ -36,12 +55,12 @@ class Emitter { final bool _alignedOutput; Emitter(ArgResults results) - : bytesPerSecond = results['bytes-per-second'] || results['verbose'], - nanosecondsPerByte = - results['nanoseconds-per-byte'] || results['verbose'], - mebibytesPerSecond = - results['mebibytes-per-second'] || results['verbose'], - _alignedOutput = results['aligned']; + : bytesPerSecond = results['bytes-per-second'] || results['verbose'], + nanosecondsPerByte = + results['nanoseconds-per-byte'] || results['verbose'], + mebibytesPerSecond = + results['mebibytes-per-second'] || results['verbose'], + _alignedOutput = results['aligned']; static final kValueRegexp = RegExp(r'^([0-9]+)'); static final kMaxLabelLength = @@ -57,7 +76,8 @@ class Emitter { ..write(': '); if (_alignedOutput) { final matches = kValueRegexp.firstMatch(valueString)!; - final valuePadding = (kMaxLabelLength - label.length) + + final valuePadding = + (kMaxLabelLength - label.length) + max(kMaxDigits - matches[1]!.length, 0); buffer..write(' ' * valuePadding); } @@ -98,9 +118,11 @@ abstract class MemoryCopyBenchmark { // to avoid discarding results that almost, but not quite, reach the minimum // duration requested. final allowedJitter = Duration( - microseconds: minDuration.inSeconds > 0 - ? (minDuration.inMicroseconds * 0.1).floor() - : 0); + microseconds: + minDuration.inSeconds > 0 + ? (minDuration.inMicroseconds * 0.1).floor() + : 0, + ); final watch = Stopwatch()..start(); while (true) { @@ -148,7 +170,9 @@ abstract class MemoryCopyBenchmark { const nanoSecondsPerSecond = 1000 * 1000 * 1000; final nanosecondsPerByte = nanoSecondsPerSecond / bytesPerSecond; emitter.printLabeledValue( - '$name(NanosecondsPerChar)', nanosecondsPerByte); + '$name(NanosecondsPerChar)', + nanosecondsPerByte, + ); } if (emitter.mebibytesPerSecond) { const bytesPerMebibyte = 1024 * 1024; @@ -168,8 +192,8 @@ abstract class Uint8ListCopyBenchmark extends MemoryCopyBenchmark { late Uint8List result; Uint8ListCopyBenchmark(String method, int bytes) - : count = bytes, - super('$bytes.$method.TypedData.Uint8', bytes); + : count = bytes, + super('$bytes.$method.TypedData.Uint8', bytes); @override void setup() { @@ -230,8 +254,8 @@ abstract class Float64ListCopyBenchmark extends MemoryCopyBenchmark { late Float64List result; Float64ListCopyBenchmark(String method, int bytes) - : count = bytes ~/ 8, - super('$bytes.$method.TypedData.Double', bytes); + : count = bytes ~/ 8, + super('$bytes.$method.TypedData.Double', bytes); static const maxSizeInElements = maxSizeInBytes ~/ 8; @@ -294,8 +318,8 @@ abstract class PointerUint8CopyBenchmark extends MemoryCopyBenchmark { late Pointer result; PointerUint8CopyBenchmark(String method, int bytes) - : count = bytes, - super('$bytes.$method.Pointer.Uint8', bytes); + : count = bytes, + super('$bytes.$method.Pointer.Uint8', bytes); @override void setup() { @@ -381,8 +405,8 @@ abstract class PointerDoubleCopyBenchmark extends MemoryCopyBenchmark { late Pointer result; PointerDoubleCopyBenchmark(String method, int bytes) - : count = bytes ~/ 8, - super('$bytes.$method.Pointer.Double', bytes); + : count = bytes ~/ 8, + super('$bytes.$method.Pointer.Double', bytes); static const maxSizeInElements = maxSizeInBytes ~/ 8; @@ -451,10 +475,11 @@ void main(List args) { List lengthsInBytes = defaultLengthsInBytes; final emitter = Emitter(results); if (results['length'].isNotEmpty) { - lengthsInBytes = (results['length'] as List) - .map(int.parse) - .where((i) => i <= maxSizeInBytes) - .toList(); + lengthsInBytes = + (results['length'] as List) + .map(int.parse) + .where((i) => i <= maxSizeInBytes) + .toList(); } final filter = results.rest.firstOrNull; final benchmarks = [ diff --git a/benchmarks/MultipleReturns/dart/MultipleReturns.dart b/benchmarks/MultipleReturns/dart/MultipleReturns.dart index a16ef744307..4d65a9ac7d9 100644 --- a/benchmarks/MultipleReturns/dart/MultipleReturns.dart +++ b/benchmarks/MultipleReturns/dart/MultipleReturns.dart @@ -69,14 +69,18 @@ ResultClass forwardedClass() => notInlinedClass(); @pragma('vm:prefer-inline') @pragma('wasm:prefer-inline') @pragma('dart2js:prefer-inline') -({int result0, String result1}) inlinedRecordNamed() => - (result0: input1, result1: input2); +({int result0, String result1}) inlinedRecordNamed() => ( + result0: input1, + result1: input2, +); @pragma('vm:never-inline') @pragma('wasm:never-inline') @pragma('dart2js:never-inline') -({int result0, String result1}) notInlinedRecordNamed() => - (result0: input1, result1: input2); +({int result0, String result1}) notInlinedRecordNamed() => ( + result0: input1, + result1: input2, +); @pragma('vm:never-inline') @pragma('wasm:never-inline') @@ -246,7 +250,7 @@ class BenchInlinedRecordNamed extends BenchmarkBase { class BenchNotInlinedRecordNamed extends BenchmarkBase { BenchNotInlinedRecordNamed() - : super('MultipleReturns.NotInlined.RecordNamed'); + : super('MultipleReturns.NotInlined.RecordNamed'); @override void run() { diff --git a/benchmarks/NativeCall/dart/NativeCall.dart b/benchmarks/NativeCall/dart/NativeCall.dart index ce36cac807b..30c4b487540 100644 --- a/benchmarks/NativeCall/dart/NativeCall.dart +++ b/benchmarks/NativeCall/dart/NativeCall.dart @@ -15,14 +15,18 @@ import 'dlopen_helper.dart'; const N = 1000; // The native library that holds all the native functions being called. -final nativeFunctionsLib = dlopenPlatformSpecific('native_functions', - path: Platform.script.resolve('../native/out/').path); +final nativeFunctionsLib = dlopenPlatformSpecific( + 'native_functions', + path: Platform.script.resolve('../native/out/').path, +); final getRootLibraryUrl = nativeFunctionsLib .lookupFunction('GetRootLibraryUrl'); -final setNativeResolverForTest = nativeFunctionsLib.lookupFunction< - Void Function(Handle), void Function(Object)>('SetNativeResolverForTest'); +final setNativeResolverForTest = nativeFunctionsLib + .lookupFunction( + 'SetNativeResolverForTest', + ); // // Benchmark fixtures. @@ -71,26 +75,27 @@ class Int64x20 extends NativeCallBenchmarkBase { @pragma('vm:external-name', 'Function20Int64') external static int f( - int a, - int b, - int c, - int d, - int e, - int f, - int g, - int h, - int i, - int j, - int k, - int l, - int m, - int n, - int o, - int p, - int q, - int r, - int s, - int t); + int a, + int b, + int c, + int d, + int e, + int f, + int g, + int h, + int i, + int j, + int k, + int l, + int m, + int n, + int o, + int p, + int q, + int r, + int s, + int t, + ); @override void run() { @@ -124,35 +129,57 @@ class Doublex20 extends NativeCallBenchmarkBase { @pragma('vm:external-name', 'Function20Double') external static double f( - double a, - double b, - double c, - double d, - double e, - double f, - double g, - double h, - double i, - double j, - double k, - double l, - double m, - double n, - double o, - double p, - double q, - double r, - double s, - double t); + double a, + double b, + double c, + double d, + double e, + double f, + double g, + double h, + double i, + double j, + double k, + double l, + double m, + double n, + double o, + double p, + double q, + double r, + double s, + double t, + ); @override void run() { double x = 0; for (int i = 0; i < N; i++) { - x += f(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, - 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0); + x += f( + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0, + 17.0, + 18.0, + 19.0, + 20.0, + ); } - final double expected = N * + final double expected = + N * (1.0 + 2.0 + 3.0 + @@ -204,26 +231,27 @@ class Handlex20 extends NativeCallBenchmarkBase { @pragma('vm:external-name', 'Function20Handle') external static Object f( - Object a, - Object b, - Object c, - Object d, - Object e, - Object f, - Object g, - Object h, - Object i, - Object j, - Object k, - Object l, - Object m, - Object n, - Object o, - Object p, - Object q, - Object r, - Object s, - Object t); + Object a, + Object b, + Object c, + Object d, + Object e, + Object f, + Object g, + Object h, + Object i, + Object j, + Object k, + Object l, + Object m, + Object n, + Object o, + Object p, + Object q, + Object r, + Object s, + Object t, + ); @override void run() { @@ -249,8 +277,28 @@ class Handlex20 extends NativeCallBenchmarkBase { final p20 = MyClass(20); Object x = p1; for (int i = 0; i < N; i++) { - x = f(x, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, - p16, p17, p18, p19, p20); + x = f( + x, + p2, + p3, + p4, + p5, + p6, + p7, + p8, + p9, + p10, + p11, + p12, + p13, + p14, + p15, + p16, + p17, + p18, + p19, + p20, + ); } expectIdentical(x, p1); } diff --git a/benchmarks/NativeCall/dart2/NativeCall.dart b/benchmarks/NativeCall/dart2/NativeCall.dart index c2dbf1347a4..8e2e0d0b7c1 100644 --- a/benchmarks/NativeCall/dart2/NativeCall.dart +++ b/benchmarks/NativeCall/dart2/NativeCall.dart @@ -17,14 +17,18 @@ import 'dlopen_helper.dart'; const N = 1000; // The native library that holds all the native functions being called. -final nativeFunctionsLib = dlopenPlatformSpecific('native_functions', - path: Platform.script.resolve('../native/out/').path); +final nativeFunctionsLib = dlopenPlatformSpecific( + 'native_functions', + path: Platform.script.resolve('../native/out/').path, +); final getRootLibraryUrl = nativeFunctionsLib .lookupFunction('GetRootLibraryUrl'); -final setNativeResolverForTest = nativeFunctionsLib.lookupFunction< - Void Function(Handle), void Function(Object)>('SetNativeResolverForTest'); +final setNativeResolverForTest = nativeFunctionsLib + .lookupFunction( + 'SetNativeResolverForTest', + ); // // Benchmark fixtures. @@ -73,26 +77,27 @@ class Int64x20 extends NativeCallBenchmarkBase { @pragma('vm:external-name', 'Function20Int64') external static int f( - int a, - int b, - int c, - int d, - int e, - int f, - int g, - int h, - int i, - int j, - int k, - int l, - int m, - int n, - int o, - int p, - int q, - int r, - int s, - int t); + int a, + int b, + int c, + int d, + int e, + int f, + int g, + int h, + int i, + int j, + int k, + int l, + int m, + int n, + int o, + int p, + int q, + int r, + int s, + int t, + ); @override void run() { @@ -126,35 +131,57 @@ class Doublex20 extends NativeCallBenchmarkBase { @pragma('vm:external-name', 'Function20Double') external static double f( - double a, - double b, - double c, - double d, - double e, - double f, - double g, - double h, - double i, - double j, - double k, - double l, - double m, - double n, - double o, - double p, - double q, - double r, - double s, - double t); + double a, + double b, + double c, + double d, + double e, + double f, + double g, + double h, + double i, + double j, + double k, + double l, + double m, + double n, + double o, + double p, + double q, + double r, + double s, + double t, + ); @override void run() { double x = 0; for (int i = 0; i < N; i++) { - x += f(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, - 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0); + x += f( + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0, + 17.0, + 18.0, + 19.0, + 20.0, + ); } - final double expected = N * + final double expected = + N * (1.0 + 2.0 + 3.0 + @@ -206,26 +233,27 @@ class Handlex20 extends NativeCallBenchmarkBase { @pragma('vm:external-name', 'Function20Handle') external static Object f( - Object a, - Object b, - Object c, - Object d, - Object e, - Object f, - Object g, - Object h, - Object i, - Object j, - Object k, - Object l, - Object m, - Object n, - Object o, - Object p, - Object q, - Object r, - Object s, - Object t); + Object a, + Object b, + Object c, + Object d, + Object e, + Object f, + Object g, + Object h, + Object i, + Object j, + Object k, + Object l, + Object m, + Object n, + Object o, + Object p, + Object q, + Object r, + Object s, + Object t, + ); @override void run() { @@ -251,8 +279,28 @@ class Handlex20 extends NativeCallBenchmarkBase { final p20 = MyClass(20); Object x = p1; for (int i = 0; i < N; i++) { - x = f(x, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, - p16, p17, p18, p19, p20); + x = f( + x, + p2, + p3, + p4, + p5, + p6, + p7, + p8, + p9, + p10, + p11, + p12, + p13, + p14, + p15, + p16, + p17, + p18, + p19, + p20, + ); } expectIdentical(x, p1); } diff --git a/benchmarks/ObjectHash/dart/ObjectHash.dart b/benchmarks/ObjectHash/dart/ObjectHash.dart index 4fcfd0771e3..6ecc3758cab 100644 --- a/benchmarks/ObjectHash/dart/ObjectHash.dart +++ b/benchmarks/ObjectHash/dart/ObjectHash.dart @@ -37,8 +37,14 @@ class Node5Manual extends Node5 { // `hashCode` calls and a 0 seed (instead of loading a unique random seed from // global late-final variable). @override - int get hashCode => _SystemHash.hash5(item1.hashCode, item2.hashCode, - item3.hashCode, item4.hashCode, item5.hashCode, 0); + int get hashCode => _SystemHash.hash5( + item1.hashCode, + item2.hashCode, + item3.hashCode, + item4.hashCode, + item5.hashCode, + 0, + ); } class Node5List extends Node5 { @@ -62,7 +68,7 @@ List generateData(Object Function(int) makeValue) { true, false, 123, - Object() + Object(), ]; data.setRange(1, 1 + exceptions.length, exceptions); return data; @@ -196,7 +202,9 @@ void generalUses() { check(_SystemHash.hash3(1, 2, 3, 0), _SystemHash.hash3(1, 2, 3, 0)); check(_SystemHash.hash4(1, 2, 3, 4, 0), _SystemHash.hash4(1, 2, 3, 4, 0)); check( - _SystemHash.hash5(1, 2, 3, 4, 5, 0), _SystemHash.hash5(1, 2, 3, 4, 5, 0)); + _SystemHash.hash5(1, 2, 3, 4, 5, 0), + _SystemHash.hash5(1, 2, 3, 4, 5, 0), + ); // Pollute hashAll argument type. check(Object.hashAll({}), Object.hashAll([])); diff --git a/benchmarks/ObjectHashPerf/dart/ObjectHashPerf.dart b/benchmarks/ObjectHashPerf/dart/ObjectHashPerf.dart index ecb6a10795c..da94a2534e3 100644 --- a/benchmarks/ObjectHashPerf/dart/ObjectHashPerf.dart +++ b/benchmarks/ObjectHashPerf/dart/ObjectHashPerf.dart @@ -37,8 +37,14 @@ class Node5Manual extends Node5 { // `hashCode` calls and a 0 seed (instead of loading a unique random seed from // global late-final variable). @override - int get hashCode => _SystemHash.hash5(item1.hashCode, item2.hashCode, - item3.hashCode, item4.hashCode, item5.hashCode, 0); + int get hashCode => _SystemHash.hash5( + item1.hashCode, + item2.hashCode, + item3.hashCode, + item4.hashCode, + item5.hashCode, + 0, + ); } class Node5List extends Node5 { @@ -62,7 +68,7 @@ List generateData(Object Function(int) makeValue) { true, false, 123, - Object() + Object(), ]; data.setRange(1, 1 + exceptions.length, exceptions); return data; @@ -196,7 +202,9 @@ void generalUses() { check(_SystemHash.hash3(1, 2, 3, 0), _SystemHash.hash3(1, 2, 3, 0)); check(_SystemHash.hash4(1, 2, 3, 4, 0), _SystemHash.hash4(1, 2, 3, 4, 0)); check( - _SystemHash.hash5(1, 2, 3, 4, 5, 0), _SystemHash.hash5(1, 2, 3, 4, 5, 0)); + _SystemHash.hash5(1, 2, 3, 4, 5, 0), + _SystemHash.hash5(1, 2, 3, 4, 5, 0), + ); // Pollute hashAll argument type. check(Object.hashAll({}), Object.hashAll([])); diff --git a/benchmarks/OmnibusDeferred/dart/OmnibusDeferred.dart b/benchmarks/OmnibusDeferred/dart/OmnibusDeferred.dart index cb497c7f98d..679d8a22fbb 100644 --- a/benchmarks/OmnibusDeferred/dart/OmnibusDeferred.dart +++ b/benchmarks/OmnibusDeferred/dart/OmnibusDeferred.dart @@ -44,38 +44,17 @@ final Map benchmarks = { lib_BigIntParsePrint.loadLibrary, () => lib_BigIntParsePrint.main(), ), - 'Iterators': Lib( - lib_Iterators.loadLibrary, - () => lib_Iterators.main([]), - ), - 'ListCopy': Lib( - lib_ListCopy.loadLibrary, - () => lib_ListCopy.main(), - ), - 'MapCopy': Lib( - lib_MapCopy.loadLibrary, - () => lib_MapCopy.main([]), - ), - 'MD5': Lib( - lib_MD5.loadLibrary, - () => lib_MD5.main(), - ), + 'Iterators': Lib(lib_Iterators.loadLibrary, () => lib_Iterators.main([])), + 'ListCopy': Lib(lib_ListCopy.loadLibrary, () => lib_ListCopy.main()), + 'MapCopy': Lib(lib_MapCopy.loadLibrary, () => lib_MapCopy.main([])), + 'MD5': Lib(lib_MD5.loadLibrary, () => lib_MD5.main()), 'RecordCollections': Lib( lib_RecordCollections.loadLibrary, () => lib_RecordCollections.main(), ), - 'RuntimeType': Lib( - lib_RuntimeType.loadLibrary, - () => lib_RuntimeType.main(), - ), - 'SHA1': Lib( - lib_SHA1.loadLibrary, - () => lib_SHA1.main(), - ), - 'SHA256': Lib( - lib_SHA256.loadLibrary, - () => lib_SHA256.main(), - ), + 'RuntimeType': Lib(lib_RuntimeType.loadLibrary, () => lib_RuntimeType.main()), + 'SHA1': Lib(lib_SHA1.loadLibrary, () => lib_SHA1.main()), + 'SHA256': Lib(lib_SHA256.loadLibrary, () => lib_SHA256.main()), 'SkeletalAnimation': Lib( lib_SkeletalAnimation.loadLibrary, () => lib_SkeletalAnimation.main(), @@ -84,26 +63,14 @@ final Map benchmarks = { lib_SkeletalAnimationSIMD.loadLibrary, () => lib_SkeletalAnimationSIMD.main(), ), - 'SwitchFSM': Lib( - lib_SwitchFSM.loadLibrary, - () => lib_SwitchFSM.main(), - ), + 'SwitchFSM': Lib(lib_SwitchFSM.loadLibrary, () => lib_SwitchFSM.main()), 'TypedDataDuplicate': Lib( lib_TypedDataDuplicate.loadLibrary, () => lib_TypedDataDuplicate.main(), ), - 'UiMatrix': Lib( - lib_UiMatrix.loadLibrary, - () => lib_UiMatrix.main(), - ), - 'Utf8Decode': Lib( - lib_Utf8Decode.loadLibrary, - () => lib_Utf8Decode.main([]), - ), - 'Utf8Encode': Lib( - lib_Utf8Encode.loadLibrary, - () => lib_Utf8Encode.main([]), - ), + 'UiMatrix': Lib(lib_UiMatrix.loadLibrary, () => lib_UiMatrix.main()), + 'Utf8Decode': Lib(lib_Utf8Decode.loadLibrary, () => lib_Utf8Decode.main([])), + 'Utf8Encode': Lib(lib_Utf8Encode.loadLibrary, () => lib_Utf8Encode.main([])), }; void main(List originalArguments) async { diff --git a/benchmarks/OmnibusDeferred/dart2/OmnibusDeferred.dart b/benchmarks/OmnibusDeferred/dart2/OmnibusDeferred.dart index a4efeca2c60..341dec15271 100644 --- a/benchmarks/OmnibusDeferred/dart2/OmnibusDeferred.dart +++ b/benchmarks/OmnibusDeferred/dart2/OmnibusDeferred.dart @@ -41,30 +41,12 @@ final Map benchmarks = { lib_BigIntParsePrint.loadLibrary, () => lib_BigIntParsePrint.main(), ), - 'ListCopy': Lib( - lib_ListCopy.loadLibrary, - () => lib_ListCopy.main(), - ), - 'MapCopy': Lib( - lib_MapCopy.loadLibrary, - () => lib_MapCopy.main([]), - ), - 'MD5': Lib( - lib_MD5.loadLibrary, - () => lib_MD5.main(), - ), - 'RuntimeType': Lib( - lib_RuntimeType.loadLibrary, - () => lib_RuntimeType.main(), - ), - 'SHA1': Lib( - lib_SHA1.loadLibrary, - () => lib_SHA1.main(), - ), - 'SHA256': Lib( - lib_SHA256.loadLibrary, - () => lib_SHA256.main(), - ), + 'ListCopy': Lib(lib_ListCopy.loadLibrary, () => lib_ListCopy.main()), + 'MapCopy': Lib(lib_MapCopy.loadLibrary, () => lib_MapCopy.main([])), + 'MD5': Lib(lib_MD5.loadLibrary, () => lib_MD5.main()), + 'RuntimeType': Lib(lib_RuntimeType.loadLibrary, () => lib_RuntimeType.main()), + 'SHA1': Lib(lib_SHA1.loadLibrary, () => lib_SHA1.main()), + 'SHA256': Lib(lib_SHA256.loadLibrary, () => lib_SHA256.main()), 'SkeletalAnimation': Lib( lib_SkeletalAnimation.loadLibrary, () => lib_SkeletalAnimation.main(), @@ -77,14 +59,8 @@ final Map benchmarks = { lib_TypedDataDuplicate.loadLibrary, () => lib_TypedDataDuplicate.main(), ), - 'Utf8Decode': Lib( - lib_Utf8Decode.loadLibrary, - () => lib_Utf8Decode.main([]), - ), - 'Utf8Encode': Lib( - lib_Utf8Encode.loadLibrary, - () => lib_Utf8Encode.main([]), - ), + 'Utf8Decode': Lib(lib_Utf8Decode.loadLibrary, () => lib_Utf8Decode.main([])), + 'Utf8Encode': Lib(lib_Utf8Encode.loadLibrary, () => lib_Utf8Encode.main([])), }; void main(List originalArguments) async { diff --git a/benchmarks/RecordCollections/dart/RecordCollections.dart b/benchmarks/RecordCollections/dart/RecordCollections.dart index 0add8527331..ba93a854677 100644 --- a/benchmarks/RecordCollections/dart/RecordCollections.dart +++ b/benchmarks/RecordCollections/dart/RecordCollections.dart @@ -28,7 +28,10 @@ class Pair { @pragma('wasm:never-inline') @pragma('dart2js:never-inline') List getPolymorphicListOfClass( - int length, bool growable, bool withValues) { + int length, + bool growable, + bool withValues, +) { if (runtimeTrue) { if (withValues) { return List.generate(length, (i) => Pair(i, i), growable: growable); @@ -44,11 +47,17 @@ List getPolymorphicListOfClass( @pragma('wasm:never-inline') @pragma('dart2js:never-inline') List getPolymorphicListOfRecords( - int length, bool growable, bool withValues) { + int length, + bool growable, + bool withValues, +) { if (runtimeTrue) { if (withValues) { - return List<(int, int)>.generate(length, (i) => (i, i), - growable: growable); + return List<(int, int)>.generate( + length, + (i) => (i, i), + growable: growable, + ); } else { return List<(int, int)>.filled(length, (-1, -1), growable: growable); } @@ -102,8 +111,11 @@ class BenchListAddPolyRecord extends BenchmarkBase { @override void run() { - final List list = - getPolymorphicListOfRecords(0, runtimeTrue, false); + final List list = getPolymorphicListOfRecords( + 0, + runtimeTrue, + false, + ); for (int i = 0; i < N; ++i) { list.add((i, i)); } @@ -127,7 +139,7 @@ class BenchListSetIndexedClass extends BenchmarkBase { class BenchListSetIndexedRecord extends BenchmarkBase { BenchListSetIndexedRecord() - : super('RecordCollections.ListSetIndexed.Record'); + : super('RecordCollections.ListSetIndexed.Record'); @override void run() { @@ -141,7 +153,7 @@ class BenchListSetIndexedRecord extends BenchmarkBase { class BenchListSetIndexedPolyClass extends BenchmarkBase { BenchListSetIndexedPolyClass() - : super('RecordCollections.ListSetIndexedPoly.Class'); + : super('RecordCollections.ListSetIndexedPoly.Class'); @override void run() { @@ -156,12 +168,15 @@ class BenchListSetIndexedPolyClass extends BenchmarkBase { class BenchListSetIndexedPolyRecord extends BenchmarkBase { BenchListSetIndexedPolyRecord() - : super('RecordCollections.ListSetIndexedPoly.Record'); + : super('RecordCollections.ListSetIndexedPoly.Record'); @override void run() { - final List list = - getPolymorphicListOfRecords(N, !runtimeTrue, false); + final List list = getPolymorphicListOfRecords( + N, + !runtimeTrue, + false, + ); for (int i = 0; i < N; ++i) { list[i] = (i, i); } @@ -173,9 +188,7 @@ class BenchListSetIndexedPolyRecord extends BenchmarkBase { class BenchListGetIndexedClass extends BenchmarkBase { BenchListGetIndexedClass() : super('RecordCollections.ListGetIndexed.Class'); - final list = [ - for (int i = 0; i < N; ++i) Pair(i, i), - ]; + final list = [for (int i = 0; i < N; ++i) Pair(i, i)]; @override void run() { @@ -189,11 +202,9 @@ class BenchListGetIndexedClass extends BenchmarkBase { class BenchListGetIndexedRecord extends BenchmarkBase { BenchListGetIndexedRecord() - : super('RecordCollections.ListGetIndexed.Record'); + : super('RecordCollections.ListGetIndexed.Record'); - final list = <(int, int)>[ - for (int i = 0; i < N; ++i) (i, i), - ]; + final list = <(int, int)>[for (int i = 0; i < N; ++i) (i, i)]; @override void run() { @@ -207,7 +218,7 @@ class BenchListGetIndexedRecord extends BenchmarkBase { class BenchListGetIndexedPolyClass extends BenchmarkBase { BenchListGetIndexedPolyClass() - : super('RecordCollections.ListGetIndexedPoly.Class'); + : super('RecordCollections.ListGetIndexedPoly.Class'); final list = getPolymorphicListOfClass(N, runtimeTrue, true) as List; @@ -223,7 +234,7 @@ class BenchListGetIndexedPolyClass extends BenchmarkBase { class BenchListGetIndexedPolyRecord extends BenchmarkBase { BenchListGetIndexedPolyRecord() - : super('RecordCollections.ListGetIndexedPoly.Record'); + : super('RecordCollections.ListGetIndexedPoly.Record'); final list = getPolymorphicListOfRecords(N, runtimeTrue, true) as List<(int, int)>; @@ -241,9 +252,7 @@ class BenchListGetIndexedPolyRecord extends BenchmarkBase { class BenchListIterateClass extends BenchmarkBase { BenchListIterateClass() : super('RecordCollections.ListIterate.Class'); - final list = [ - for (int i = 0; i < N; ++i) Pair(i, i), - ]; + final list = [for (int i = 0; i < N; ++i) Pair(i, i)]; @override void run() { @@ -258,9 +267,7 @@ class BenchListIterateClass extends BenchmarkBase { class BenchListIterateRecord extends BenchmarkBase { BenchListIterateRecord() : super('RecordCollections.ListIterate.Record'); - final list = <(int, int)>[ - for (int i = 0; i < N; ++i) (i, i), - ]; + final list = <(int, int)>[for (int i = 0; i < N; ++i) (i, i)]; @override void run() { @@ -274,7 +281,7 @@ class BenchListIterateRecord extends BenchmarkBase { class BenchListIteratePolyClass extends BenchmarkBase { BenchListIteratePolyClass() - : super('RecordCollections.ListIteratePoly.Class'); + : super('RecordCollections.ListIteratePoly.Class'); final list = getPolymorphicListOfClass(N, runtimeTrue, true) as List; @@ -290,7 +297,7 @@ class BenchListIteratePolyClass extends BenchmarkBase { class BenchListIteratePolyRecord extends BenchmarkBase { BenchListIteratePolyRecord() - : super('RecordCollections.ListIteratePoly.Record'); + : super('RecordCollections.ListIteratePoly.Record'); final list = getPolymorphicListOfRecords(N, runtimeTrue, true) as List<(int, int)>; @@ -360,9 +367,7 @@ class BenchMapAddRecordValue extends BenchmarkBase { class BenchMapLookupClass extends BenchmarkBase { BenchMapLookupClass() : super('RecordCollections.MapLookup.Class'); - final map = { - for (int i = 0; i < N; ++i) Pair(i, i): i, - }; + final map = {for (int i = 0; i < N; ++i) Pair(i, i): i}; @override void run() { @@ -377,9 +382,7 @@ class BenchMapLookupClass extends BenchmarkBase { class BenchMapLookupRecord extends BenchmarkBase { BenchMapLookupRecord() : super('RecordCollections.MapLookup.Record'); - final map = <(int, int), int>{ - for (int i = 0; i < N; ++i) (i, i): i, - }; + final map = <(int, int), int>{for (int i = 0; i < N; ++i) (i, i): i}; @override void run() { @@ -420,9 +423,7 @@ class BenchSetAddRecord extends BenchmarkBase { class BenchSetLookupClass extends BenchmarkBase { BenchSetLookupClass() : super('RecordCollections.SetLookup.Class'); - final set = { - for (int i = 0; i < N ~/ 2; ++i) Pair(i * 2, i * 2), - }; + final set = {for (int i = 0; i < N ~/ 2; ++i) Pair(i * 2, i * 2)}; @override void run() { @@ -437,9 +438,7 @@ class BenchSetLookupClass extends BenchmarkBase { class BenchSetLookupRecord extends BenchmarkBase { BenchSetLookupRecord() : super('RecordCollections.SetLookup.Record'); - final set = <(int, int)>{ - for (int i = 0; i < N ~/ 2; ++i) (i * 2, i * 2), - }; + final set = <(int, int)>{for (int i = 0; i < N ~/ 2; ++i) (i * 2, i * 2)}; @override void run() { diff --git a/benchmarks/Richards/dart/Richards.dart b/benchmarks/Richards/dart/Richards.dart index 3d8ed86e37c..37194089b56 100644 --- a/benchmarks/Richards/dart/Richards.dart +++ b/benchmarks/Richards/dart/Richards.dart @@ -71,8 +71,10 @@ class Richards extends BenchmarkBase { if (scheduler.queueCount != EXPECTED_QUEUE_COUNT || scheduler.holdCount != EXPECTED_HOLD_COUNT) { - print('Error during execution: queueCount = ${scheduler.queueCount}' - ', holdCount = ${scheduler.holdCount}.'); + print( + 'Error during execution: queueCount = ${scheduler.queueCount}' + ', holdCount = ${scheduler.holdCount}.', + ); } if (EXPECTED_QUEUE_COUNT != scheduler.queueCount) { throw 'bad scheduler queue-count'; @@ -114,8 +116,10 @@ class Scheduler { TaskControlBlock? currentTcb; int currentId = Richards.ID_IDLE; TaskControlBlock? list; - final List blocks = - List.filled(Richards.NUMBER_OF_IDS, null); + final List blocks = List.filled( + Richards.NUMBER_OF_IDS, + null, + ); /// Add an idle task to this scheduler. void addIdleTask(int id, int priority, Packet? queue, int count) { @@ -213,7 +217,7 @@ class TaskControlBlock { int state; TaskControlBlock(this.link, this.id, this.priority, this.queue, this.task) - : state = queue == null ? STATE_SUSPENDED : STATE_SUSPENDED_RUNNABLE; + : state = queue == null ? STATE_SUSPENDED : STATE_SUSPENDED_RUNNABLE; /// The task is running and is currently scheduled. static const int STATE_RUNNING = 0; diff --git a/benchmarks/Richards/dart2/Richards.dart b/benchmarks/Richards/dart2/Richards.dart index 5e74efe4f2e..bf9195ed571 100644 --- a/benchmarks/Richards/dart2/Richards.dart +++ b/benchmarks/Richards/dart2/Richards.dart @@ -73,8 +73,10 @@ class Richards extends BenchmarkBase { if (scheduler.queueCount != EXPECTED_QUEUE_COUNT || scheduler.holdCount != EXPECTED_HOLD_COUNT) { - print('Error during execution: queueCount = ${scheduler.queueCount}' - ', holdCount = ${scheduler.holdCount}.'); + print( + 'Error during execution: queueCount = ${scheduler.queueCount}' + ', holdCount = ${scheduler.holdCount}.', + ); } if (EXPECTED_QUEUE_COUNT != scheduler.queueCount) { throw 'bad scheduler queue-count'; @@ -116,8 +118,10 @@ class Scheduler { TaskControlBlock currentTcb; int currentId; TaskControlBlock list; - List blocks = - List.filled(Richards.NUMBER_OF_IDS, null); + List blocks = List.filled( + Richards.NUMBER_OF_IDS, + null, + ); /// Add an idle task to this scheduler. void addIdleTask(int id, int priority, Packet queue, int count) { diff --git a/benchmarks/RuntimeType/dart/RuntimeType.dart b/benchmarks/RuntimeType/dart/RuntimeType.dart index a9651979560..a906343e64a 100644 --- a/benchmarks/RuntimeType/dart/RuntimeType.dart +++ b/benchmarks/RuntimeType/dart/RuntimeType.dart @@ -78,17 +78,17 @@ class WidgetCanUpdateBenchmark extends BenchmarkBase { // All widgets have different types. static List _widgets() => [ - AWidget(), - BWidget(), - CWidget(), - DWidget(), - EWidget(), - FWidget(), - WWidget(), - WWidget(ref: const BWidget()), - WWidget(ref: CWidget()), - const WWidget(ref: DWidget()), - ]; + AWidget(), + BWidget(), + CWidget(), + DWidget(), + EWidget(), + FWidget(), + WWidget(), + WWidget(ref: const BWidget()), + WWidget(ref: CWidget()), + const WWidget(ref: DWidget()), + ]; // Bulk up list to reduce loop overheads. final List widgets = _widgets() + _widgets() + _widgets(); @@ -116,17 +116,17 @@ class ValueKeyEqualBenchmark extends BenchmarkBase { // All widgets the same class but distinguished on keys. static List _widgets() => [ - AWidget(), - AWidget(key: ValueKey(1)), - AWidget(key: ValueKey(1)), - AWidget(key: ValueKey(2)), - AWidget(key: ValueKey(2)), - AWidget(key: ValueKey(3)), - AWidget(key: ValueKey('one')), - AWidget(key: ValueKey('two')), - AWidget(key: ValueKey('three')), - AWidget(key: ValueKey(Duration(seconds: 5))), - ]; + AWidget(), + AWidget(key: ValueKey(1)), + AWidget(key: ValueKey(1)), + AWidget(key: ValueKey(2)), + AWidget(key: ValueKey(2)), + AWidget(key: ValueKey(3)), + AWidget(key: ValueKey('one')), + AWidget(key: ValueKey('two')), + AWidget(key: ValueKey('three')), + AWidget(key: ValueKey(Duration(seconds: 5))), + ]; // Bulk up list to reduce loop overheads. final List widgets = _widgets() + _widgets() + _widgets(); @@ -164,10 +164,7 @@ void pollute() { void main() { pollute(); - final benchmarks = [ - WidgetCanUpdateBenchmark(), - ValueKeyEqualBenchmark(), - ]; + final benchmarks = [WidgetCanUpdateBenchmark(), ValueKeyEqualBenchmark()]; // Warm up all benchmarks before running any. benchmarks.forEach((bm) => bm.run()); diff --git a/benchmarks/RuntimeType/dart2/RuntimeType.dart b/benchmarks/RuntimeType/dart2/RuntimeType.dart index 1a7b6d62f6f..1da9741419e 100644 --- a/benchmarks/RuntimeType/dart2/RuntimeType.dart +++ b/benchmarks/RuntimeType/dart2/RuntimeType.dart @@ -80,17 +80,17 @@ class WidgetCanUpdateBenchmark extends BenchmarkBase { // All widgets have different types. static List _widgets() => [ - AWidget(), - BWidget(), - CWidget(), - DWidget(), - EWidget(), - FWidget(), - WWidget(), - WWidget(ref: const BWidget()), - WWidget(ref: CWidget()), - const WWidget(ref: DWidget()), - ]; + AWidget(), + BWidget(), + CWidget(), + DWidget(), + EWidget(), + FWidget(), + WWidget(), + WWidget(ref: const BWidget()), + WWidget(ref: CWidget()), + const WWidget(ref: DWidget()), + ]; // Bulk up list to reduce loop overheads. final List widgets = _widgets() + _widgets() + _widgets(); @@ -118,17 +118,17 @@ class ValueKeyEqualBenchmark extends BenchmarkBase { // All widgets the same class but distinguished on keys. static List _widgets() => [ - AWidget(), - AWidget(key: ValueKey(1)), - AWidget(key: ValueKey(1)), - AWidget(key: ValueKey(2)), - AWidget(key: ValueKey(2)), - AWidget(key: ValueKey(3)), - AWidget(key: ValueKey('one')), - AWidget(key: ValueKey('two')), - AWidget(key: ValueKey('three')), - AWidget(key: ValueKey(Duration(seconds: 5))), - ]; + AWidget(), + AWidget(key: ValueKey(1)), + AWidget(key: ValueKey(1)), + AWidget(key: ValueKey(2)), + AWidget(key: ValueKey(2)), + AWidget(key: ValueKey(3)), + AWidget(key: ValueKey('one')), + AWidget(key: ValueKey('two')), + AWidget(key: ValueKey('three')), + AWidget(key: ValueKey(Duration(seconds: 5))), + ]; // Bulk up list to reduce loop overheads. final List widgets = _widgets() + _widgets() + _widgets(); @@ -166,10 +166,7 @@ void pollute() { void main() { pollute(); - final benchmarks = [ - WidgetCanUpdateBenchmark(), - ValueKeyEqualBenchmark(), - ]; + final benchmarks = [WidgetCanUpdateBenchmark(), ValueKeyEqualBenchmark()]; // Warm up all benchmarks before running any. benchmarks.forEach((bm) => bm.run()); diff --git a/benchmarks/SDKArtifactSizes/dart/SDKArtifactSizes.dart b/benchmarks/SDKArtifactSizes/dart/SDKArtifactSizes.dart index b9ea89b0d99..8fe2738e0c4 100644 --- a/benchmarks/SDKArtifactSizes/dart/SDKArtifactSizes.dart +++ b/benchmarks/SDKArtifactSizes/dart/SDKArtifactSizes.dart @@ -6,10 +6,7 @@ import 'dart:io'; -const executables = [ - 'dart', - 'dartaotruntime', -]; +const executables = ['dart', 'dartaotruntime']; const libs = [ 'vm_platform_strong.dill', @@ -29,9 +26,7 @@ const snapshots = [ 'kernel_worker', ]; -const resources = [ - 'devtools', -]; +const resources = ['devtools']; void reportFileSize(String path, String name) { try { @@ -60,8 +55,9 @@ void reportDirectorySize(String path, String name) async { } void main() { - final topDirIndex = - Platform.resolvedExecutable.lastIndexOf(Platform.pathSeparator); + final topDirIndex = Platform.resolvedExecutable.lastIndexOf( + Platform.pathSeparator, + ); final rootDir = Platform.resolvedExecutable.substring(0, topDirIndex); for (final executable in executables) { diff --git a/benchmarks/SDKArtifactSizes/dart2/SDKArtifactSizes.dart b/benchmarks/SDKArtifactSizes/dart2/SDKArtifactSizes.dart index ad78f7fbcf6..52f9b106c4a 100644 --- a/benchmarks/SDKArtifactSizes/dart2/SDKArtifactSizes.dart +++ b/benchmarks/SDKArtifactSizes/dart2/SDKArtifactSizes.dart @@ -8,10 +8,7 @@ import 'dart:io'; -const executables = [ - 'dart', - 'dartaotruntime', -]; +const executables = ['dart', 'dartaotruntime']; const libs = [ 'vm_platform_strong.dill', @@ -31,9 +28,7 @@ const snapshots = [ 'kernel_worker', ]; -const resources = [ - 'devtools', -]; +const resources = ['devtools']; void reportFileSize(String path, String name) { try { @@ -62,8 +57,9 @@ void reportDirectorySize(String path, String name) async { } void main() { - final topDirIndex = - Platform.resolvedExecutable.lastIndexOf(Platform.pathSeparator); + final topDirIndex = Platform.resolvedExecutable.lastIndexOf( + Platform.pathSeparator, + ); final rootDir = Platform.resolvedExecutable.substring(0, topDirIndex); for (final executable in executables) { diff --git a/benchmarks/SHA1/dart/sha1.dart b/benchmarks/SHA1/dart/sha1.dart index 1b9f7a0339b..dfca652747d 100644 --- a/benchmarks/SHA1/dart/sha1.dart +++ b/benchmarks/SHA1/dart/sha1.dart @@ -13,8 +13,8 @@ class SHA1Bench extends BenchmarkBase { List data; SHA1Bench() - : data = List.generate(size, (i) => i % 256, growable: false), - super('SHA1'); + : data = List.generate(size, (i) => i % 256, growable: false), + super('SHA1'); @override void run() { diff --git a/benchmarks/SHA256/dart/sha256.dart b/benchmarks/SHA256/dart/sha256.dart index cb580b34b0c..0c267d1e0e1 100644 --- a/benchmarks/SHA256/dart/sha256.dart +++ b/benchmarks/SHA256/dart/sha256.dart @@ -14,8 +14,8 @@ class SHA256Bench extends BenchmarkBase { List data; SHA256Bench() - : data = List.generate(size, (i) => i % 256, growable: false), - super('SHA256'); + : data = List.generate(size, (i) => i % 256, growable: false), + super('SHA256'); @override void run() { diff --git a/benchmarks/SendPort/dart/SendPort.dart b/benchmarks/SendPort/dart/SendPort.dart index fb950b58f30..8bec5b66bb5 100644 --- a/benchmarks/SendPort/dart/SendPort.dart +++ b/benchmarks/SendPort/dart/SendPort.dart @@ -7,7 +7,8 @@ import 'dart:convert'; import 'dart:isolate'; // (Same data as used in our other Json* benchmarks) -final data = '{"summary":{"turnover":0.3736,"correlation2":0.' +final data = + '{"summary":{"turnover":0.3736,"correlation2":0.' '7147,"concentration":0.3652,"beta":0.8814,"totalValue":1.3' '091078259E8,"correlation":0.7217},"watchlist":[],"shortCash' '":-1611000,"holdings":[{"type":"LONG","commission":1040' @@ -229,11 +230,7 @@ Future main(args) async { assert(json500KB.length == 498169); final String json5MB = json.encode({ - '1': [ - json500KBDecoded, - json500KBDecoded, - json500KBDecoded, - ], + '1': [json500KBDecoded, json500KBDecoded, json500KBDecoded], '2': [json500KBDecoded, json500KBDecoded, json500KBDecoded], '3': [json500KBDecoded, json500KBDecoded, json500KBDecoded], '4': json500KBDecoded, diff --git a/benchmarks/SendPort/dart2/SendPort.dart b/benchmarks/SendPort/dart2/SendPort.dart index a97acf30f7b..459b608a693 100644 --- a/benchmarks/SendPort/dart2/SendPort.dart +++ b/benchmarks/SendPort/dart2/SendPort.dart @@ -9,7 +9,8 @@ import 'dart:convert'; import 'dart:isolate'; // (Same data as used in our other Json* benchmarks) -final data = '{"summary":{"turnover":0.3736,"correlation2":0.' +final data = + '{"summary":{"turnover":0.3736,"correlation2":0.' '7147,"concentration":0.3652,"beta":0.8814,"totalValue":1.3' '091078259E8,"correlation":0.7217},"watchlist":[],"shortCash' '":-1611000,"holdings":[{"type":"LONG","commission":1040' @@ -231,11 +232,7 @@ Future main(args) async { assert(json500KB.length == 498169); final String json5MB = json.encode({ - '1': [ - json500KBDecoded, - json500KBDecoded, - json500KBDecoded, - ], + '1': [json500KBDecoded, json500KBDecoded, json500KBDecoded], '2': [json500KBDecoded, json500KBDecoded, json500KBDecoded], '3': [json500KBDecoded, json500KBDecoded, json500KBDecoded], '4': json500KBDecoded, diff --git a/benchmarks/SoundSplayTreeSieve/dart/SoundSplayTreeSieve.dart b/benchmarks/SoundSplayTreeSieve/dart/SoundSplayTreeSieve.dart index 19a0708f26a..a6d5716dd0b 100644 --- a/benchmarks/SoundSplayTreeSieve/dart/SoundSplayTreeSieve.dart +++ b/benchmarks/SoundSplayTreeSieve/dart/SoundSplayTreeSieve.dart @@ -73,14 +73,19 @@ void busyWork() { exercise(UnmodifiableListView(L3)); exercise(L1.asMap().values); exercise(L1.toList().asMap().values); - final M1 = - Map.fromIterables(['a', 'b', 'c', 'd', 'e'], L1); + final M1 = Map.fromIterables([ + 'a', + 'b', + 'c', + 'd', + 'e', + ], L1); final M2 = const { 'a': 104, 'b': 101, 'c': 108, 'd': 108, - 'e': 111 + 'e': 111, }; exercise(M1.values); exercise(M2.values); diff --git a/benchmarks/SoundSplayTreeSieve/dart2/SoundSplayTreeSieve.dart b/benchmarks/SoundSplayTreeSieve/dart2/SoundSplayTreeSieve.dart index 5c672d416be..87578d154e7 100644 --- a/benchmarks/SoundSplayTreeSieve/dart2/SoundSplayTreeSieve.dart +++ b/benchmarks/SoundSplayTreeSieve/dart2/SoundSplayTreeSieve.dart @@ -74,14 +74,19 @@ void busyWork() { exercise(UnmodifiableListView(L3)); exercise(L1.asMap().values); exercise(L1.toList().asMap().values); - final M1 = - Map.fromIterables(['a', 'b', 'c', 'd', 'e'], L1); + final M1 = Map.fromIterables([ + 'a', + 'b', + 'c', + 'd', + 'e', + ], L1); final M2 = const { 'a': 104, 'b': 101, 'c': 108, 'd': 108, - 'e': 111 + 'e': 111, }; exercise(M1.values); exercise(M2.values); diff --git a/benchmarks/Startup/dart/Startup.dart b/benchmarks/Startup/dart/Startup.dart index f60d456c10c..ad425801b84 100644 --- a/benchmarks/Startup/dart/Startup.dart +++ b/benchmarks/Startup/dart/Startup.dart @@ -30,7 +30,7 @@ Future main(List args) async { '--timeline_recorder=file:$timelinePath', '--timeline_streams=VM,Isolate,Embedder', Platform.script.toFilePath(), - '--child' + '--child', ]); if (p.exitCode != 0) { print(p.stdout); @@ -57,8 +57,9 @@ Future main(List args) async { void report(String name, String? isolateId) { var filtered = events.where((event) => event['name'] == name); if (isolateId != null) { - filtered = - filtered.where((event) => event['args']['isolateId'] == isolateId); + filtered = filtered.where( + (event) => event['args']['isolateId'] == isolateId, + ); } var micros; final durations = filtered.where((event) => event['ph'] == 'X'); diff --git a/benchmarks/Startup/dart2/Startup.dart b/benchmarks/Startup/dart2/Startup.dart index b79e3a3ccf9..54cb577b7be 100644 --- a/benchmarks/Startup/dart2/Startup.dart +++ b/benchmarks/Startup/dart2/Startup.dart @@ -32,7 +32,7 @@ Future main(List args) async { '--timeline_recorder=file:$timelinePath', '--timeline_streams=VM,Isolate,Embedder', Platform.script.toFilePath(), - '--child' + '--child', ]); if (p.exitCode != 0) { print(p.stdout); @@ -59,8 +59,9 @@ Future main(List args) async { void report(String name, String isolateId) { var filtered = events.where((event) => event['name'] == name); if (isolateId != null) { - filtered = - filtered.where((event) => event['args']['isolateId'] == isolateId); + filtered = filtered.where( + (event) => event['args']['isolateId'] == isolateId, + ); } var micros; final durations = filtered.where((event) => event['ph'] == 'X'); diff --git a/benchmarks/StringPool/dart/version1a.dart b/benchmarks/StringPool/dart/version1a.dart index ab4fc9cbc77..3f9d66ba2d5 100644 --- a/benchmarks/StringPool/dart/version1a.dart +++ b/benchmarks/StringPool/dart/version1a.dart @@ -20,7 +20,7 @@ List Function(String)> version1ax1500() { _f12, _f13, _f14, - _f15 + _f15, ]; } diff --git a/benchmarks/StringPool/dart/version1b.dart b/benchmarks/StringPool/dart/version1b.dart index c168c17a144..94049fe489e 100644 --- a/benchmarks/StringPool/dart/version1b.dart +++ b/benchmarks/StringPool/dart/version1b.dart @@ -20,7 +20,7 @@ List Function(String)> version1bx1500() { _g12, _g13, _g14, - _g15 + _g15, ]; } diff --git a/benchmarks/StringPool/dart/version2.dart b/benchmarks/StringPool/dart/version2.dart index b75ec6a23a1..9b345839d5a 100644 --- a/benchmarks/StringPool/dart/version2.dart +++ b/benchmarks/StringPool/dart/version2.dart @@ -18,7 +18,7 @@ List Function(String)> version2x1500() { _h12, _h13, _h14, - _h15 + _h15, ]; } diff --git a/benchmarks/SubtypeTestCache/generate.dart b/benchmarks/SubtypeTestCache/generate.dart index b60c1cfea78..8a70731e058 100644 --- a/benchmarks/SubtypeTestCache/generate.dart +++ b/benchmarks/SubtypeTestCache/generate.dart @@ -22,7 +22,7 @@ const List assertionCounts = [ 250, 500, 750, - 1000 + 1000, ]; void generateBenchmarkClassesAndUtilities(IOSink output) { @@ -151,7 +151,10 @@ const instances = [ void main() { final dartFilePath = path.join( - path.dirname(Platform.script.path), 'dart', '$benchmarkName.dart'); + path.dirname(Platform.script.path), + 'dart', + '$benchmarkName.dart', + ); final dartSink = File(dartFilePath).openWrite(); generateBenchmarkClassesAndUtilities(dartSink); dartSink..flush(); diff --git a/benchmarks/SwitchFSM/dart/SwitchFSM.dart b/benchmarks/SwitchFSM/dart/SwitchFSM.dart index 899529a3d9b..cb1214baf6e 100644 --- a/benchmarks/SwitchFSM/dart/SwitchFSM.dart +++ b/benchmarks/SwitchFSM/dart/SwitchFSM.dart @@ -57,14 +57,53 @@ class Benchmark extends BenchmarkBase { check('01010101', true); check('10000000', false); check('001010101', false); - check('11000000' '00000000', false); - check('11000000' '10111111', true); - check('11000000' '11111111', false); - check('11100000' '00000000' '00000000', false); - check('11100000' '10000000' '00000000', false); - check('11100000' '10111111' '10111111', true); - check('11110111' '10111111' '10111111' '01111111', false); - check('11110111' '10111111' '10111111' '10111111', true); + check( + '11000000' + '00000000', + false, + ); + check( + '11000000' + '10111111', + true, + ); + check( + '11000000' + '11111111', + false, + ); + check( + '11100000' + '00000000' + '00000000', + false, + ); + check( + '11100000' + '10000000' + '00000000', + false, + ); + check( + '11100000' + '10111111' + '10111111', + true, + ); + check( + '11110111' + '10111111' + '10111111' + '01111111', + false, + ); + check( + '11110111' + '10111111' + '10111111' + '10111111', + true, + ); Expect.equals(testInputLength, testInput.length); } @@ -74,7 +113,8 @@ class Benchmark extends BenchmarkBase { static String makeTestInput(int length) { // The test input uses most states of the FSM. It is repeated and padded to // make the length 1000. - final testPattern = '' + final testPattern = + '' '11110111101111111011111110111111' '111011111011111110111111' '1101111110111111'; diff --git a/benchmarks/TypeLiteral/dart/TypeLiteral.dart b/benchmarks/TypeLiteral/dart/TypeLiteral.dart index 24d8f59d962..8bc6479f36f 100644 --- a/benchmarks/TypeLiteral/dart/TypeLiteral.dart +++ b/benchmarks/TypeLiteral/dart/TypeLiteral.dart @@ -53,18 +53,16 @@ void main() { } return iterations; }).report(); - SyncCallBenchmark('TypeLiteral.GenericFunction.ListOfNullableT.nullableInt', - () { - for (int i = 0; i < iterations; ++i) { - getListOfNullableT(); - } - return iterations; - }).report(); - final foos = >[ - Foo(), - Foo(), - Foo(), - ]; + SyncCallBenchmark( + 'TypeLiteral.GenericFunction.ListOfNullableT.nullableInt', + () { + for (int i = 0; i < iterations; ++i) { + getListOfNullableT(); + } + return iterations; + }, + ).report(); + final foos = >[Foo(), Foo(), Foo()]; final Foo fooInt = foos[int.parse('0')]; final Foo fooNullableInt = foos[int.parse('1')]; final Foo fooDynamic = foos[int.parse('2')]; diff --git a/benchmarks/TypedData/dart/TypedData.dart b/benchmarks/TypedData/dart/TypedData.dart index 660bf73fcdb..3d48bb44eb5 100644 --- a/benchmarks/TypedData/dart/TypedData.dart +++ b/benchmarks/TypedData/dart/TypedData.dart @@ -706,7 +706,7 @@ class Uint8ListViewVarBench extends BenchmarkBase { class Uint8ClampedListViewVarBench extends BenchmarkBase { var list = Uint8ClampedList.view(Uint8ClampedList(N).buffer); Uint8ClampedListViewVarBench() - : super('TypedData.Uint8ClampedListViewVarBench'); + : super('TypedData.Uint8ClampedListViewVarBench'); @override void run() { doSetUint8ClampedVar(list); diff --git a/benchmarks/TypedData/dart2/TypedData.dart b/benchmarks/TypedData/dart2/TypedData.dart index be9b38167ab..89bcac8f2c7 100644 --- a/benchmarks/TypedData/dart2/TypedData.dart +++ b/benchmarks/TypedData/dart2/TypedData.dart @@ -707,7 +707,7 @@ class Uint8ListViewVarBench extends BenchmarkBase { class Uint8ClampedListViewVarBench extends BenchmarkBase { var list = Uint8ClampedList.view(Uint8ClampedList(N).buffer); Uint8ClampedListViewVarBench() - : super('TypedData.Uint8ClampedListViewVarBench'); + : super('TypedData.Uint8ClampedListViewVarBench'); @override void run() { doSetUint8ClampedVar(list); diff --git a/benchmarks/TypedDataDuplicate/dart/TypedDataDuplicate.dart b/benchmarks/TypedDataDuplicate/dart/TypedDataDuplicate.dart index f5086f8633d..6787d641df4 100644 --- a/benchmarks/TypedDataDuplicate/dart/TypedDataDuplicate.dart +++ b/benchmarks/TypedDataDuplicate/dart/TypedDataDuplicate.dart @@ -14,7 +14,7 @@ abstract class Uint8ListCopyBenchmark extends BenchmarkBase { late Uint8List result; Uint8ListCopyBenchmark(String method, this.size) - : super('TypedDataDuplicate.Uint8List.$size.$method'); + : super('TypedDataDuplicate.Uint8List.$size.$method'); @override void setup() { @@ -63,7 +63,7 @@ abstract class Float64ListCopyBenchmark extends BenchmarkBase { late Float64List result; Float64ListCopyBenchmark(String method, this.size) - : super('TypedDataDuplicate.Float64List.$size.$method'); + : super('TypedDataDuplicate.Float64List.$size.$method'); @override void setup() { @@ -111,12 +111,12 @@ void main() { final benchmarks = [ for (int size in sizes) ...[ Uint8ListCopyViaLoopBenchmark(size), - Uint8ListCopyViaFromListBenchmark(size) + Uint8ListCopyViaFromListBenchmark(size), ], for (int size in sizes) ...[ Float64ListCopyViaLoopBenchmark(size), - Float64ListCopyViaFromListBenchmark(size) - ] + Float64ListCopyViaFromListBenchmark(size), + ], ]; for (var bench in benchmarks) { bench.report(); diff --git a/benchmarks/TypedDataDuplicate/dart2/TypedDataDuplicate.dart b/benchmarks/TypedDataDuplicate/dart2/TypedDataDuplicate.dart index 022a04eb09d..676f6006c4e 100644 --- a/benchmarks/TypedDataDuplicate/dart2/TypedDataDuplicate.dart +++ b/benchmarks/TypedDataDuplicate/dart2/TypedDataDuplicate.dart @@ -16,7 +16,7 @@ abstract class Uint8ListCopyBenchmark extends BenchmarkBase { Uint8List result; Uint8ListCopyBenchmark(String method, this.size) - : super('TypedDataDuplicate.Uint8List.$size.$method'); + : super('TypedDataDuplicate.Uint8List.$size.$method'); @override void setup() { @@ -65,7 +65,7 @@ abstract class Float64ListCopyBenchmark extends BenchmarkBase { Float64List result; Float64ListCopyBenchmark(String method, this.size) - : super('TypedDataDuplicate.Float64List.$size.$method'); + : super('TypedDataDuplicate.Float64List.$size.$method'); @override void setup() { @@ -113,12 +113,12 @@ void main() { final benchmarks = [ for (int size in sizes) ...[ Uint8ListCopyViaLoopBenchmark(size), - Uint8ListCopyViaFromListBenchmark(size) + Uint8ListCopyViaFromListBenchmark(size), ], for (int size in sizes) ...[ Float64ListCopyViaLoopBenchmark(size), - Float64ListCopyViaFromListBenchmark(size) - ] + Float64ListCopyViaFromListBenchmark(size), + ], ]; for (var bench in benchmarks) { bench.report(); diff --git a/benchmarks/TypedDataPoly/dart/TypedDataPoly.dart b/benchmarks/TypedDataPoly/dart/TypedDataPoly.dart index b1a215bdac9..279b7ed2d56 100644 --- a/benchmarks/TypedDataPoly/dart/TypedDataPoly.dart +++ b/benchmarks/TypedDataPoly/dart/TypedDataPoly.dart @@ -59,8 +59,8 @@ class Base extends BenchmarkBase { class Monomorphic extends Base { final Uint8List data1; Monomorphic(int n) - : data1 = Uint8List(n)..setToOnes(), - super('TypedDataPoly.mono.array', n); + : data1 = Uint8List(n)..setToOnes(), + super('TypedDataPoly.mono.array', n); /// An identical [sum] method appears in each benchmark so the compiler /// can specialize the method according to different sets of input @@ -99,8 +99,8 @@ class Monomorphic extends Base { class Baseline extends Base { final Uint8List data1; Baseline(int n) - : data1 = Uint8List(n)..setToOnes(), - super('TypedDataPoly.baseline', n); + : data1 = Uint8List(n)..setToOnes(), + super('TypedDataPoly.baseline', n); @pragma('vm:never-inline') @pragma('wasm:never-inline') @@ -132,7 +132,7 @@ class Polymorphic1 extends Base { final List data1; final List data2; Polymorphic1._(int n, String variant, this.data1, this.data2) - : super('TypedDataPoly.A_V.$variant', n); + : super('TypedDataPoly.A_V.$variant', n); factory Polymorphic1(int n, String variant) { final data1 = Uint8List(n)..setToOnes(); @@ -184,7 +184,7 @@ class Polymorphic2 extends Base { final List data1; final List data2; Polymorphic2._(int n, String variant, this.data1, this.data2) - : super('TypedDataPoly.A_UV.$variant', n); + : super('TypedDataPoly.A_UV.$variant', n); factory Polymorphic2(int n, String variant) { final data1 = Uint8List(n)..setToOnes(); @@ -228,7 +228,7 @@ class Polymorphic3 extends Base { final List data1; final List data2; Polymorphic3._(int n, String variant, this.data1, this.data2) - : super('TypedDataPoly.A_VUV.$variant', n); + : super('TypedDataPoly.A_VUV.$variant', n); factory Polymorphic3(int n, String variant) { final data1 = Uint8List(n)..setToOnes(); final view1 = Uint8List.sublistView(Uint8List(n + 1)..setToOnes(), 1); @@ -271,7 +271,7 @@ class Polymorphic4 extends Base { final List data1; final List data2; Polymorphic4._(int n, String variant, this.data1, this.data2) - : super('TypedDataPoly.A_UVx5.$variant', n); + : super('TypedDataPoly.A_UVx5.$variant', n); factory Polymorphic4(int n, String variant) { final data1 = Uint8List(n)..setToOnes(); @@ -327,19 +327,19 @@ class Polymorphic5 extends Base { final List data9; final List data10; Polymorphic5._( - int n, - String variant, - this.data1, - this.data2, - this.data3, - this.data4, - this.data5, - this.data6, - this.data7, - this.data8, - this.data9, - this.data10) - : super('TypedDataPoly.mega.$variant', n); + int n, + String variant, + this.data1, + this.data2, + this.data3, + this.data4, + this.data5, + this.data6, + this.data7, + this.data8, + this.data9, + this.data10, + ) : super('TypedDataPoly.mega.$variant', n); factory Polymorphic5(int n, String variant) { final data1 = Uint8List(n)..setToOnes(); @@ -355,12 +355,36 @@ class Polymorphic5 extends Base { final data10 = data5.asUnmodifiableView(); if (variant == 'array') { - return Polymorphic5._(n, variant, data1, data1, data1, data1, data1, - data1, data1, data1, data1, data1); + return Polymorphic5._( + n, + variant, + data1, + data1, + data1, + data1, + data1, + data1, + data1, + data1, + data1, + data1, + ); } if (variant == 'mixed') { - return Polymorphic5._(n, variant, data1, data2, data3, data4, data5, - data6, data7, data8, data9, data10); + return Polymorphic5._( + n, + variant, + data1, + data2, + data3, + data4, + data5, + data6, + data7, + data8, + data9, + data10, + ); } throw UnimplementedError('No variant "$variant"'); } @@ -449,8 +473,8 @@ void main(List commandLineArguments) { Polymorphic4(length, 'view'), // Polymorphic5(length, 'array'), - Polymorphic5(length, 'mixed') - ] + Polymorphic5(length, 'mixed'), + ], ]; // Warmup all benchmarks to ensure JIT compilers see full polymorphism. diff --git a/benchmarks/UiMatrix/dart/UiMatrixHarness.dart b/benchmarks/UiMatrix/dart/UiMatrixHarness.dart index e7aa7947060..d2f227385b5 100644 --- a/benchmarks/UiMatrix/dart/UiMatrixHarness.dart +++ b/benchmarks/UiMatrix/dart/UiMatrixHarness.dart @@ -72,7 +72,7 @@ class InstantiateIdentityMatrix4 extends BenchmarkBase { class InstantiateIdentityUiMatrix extends BenchmarkBase { InstantiateIdentityUiMatrix() - : super('UiMatrix.Instantiate_Identity_UiMatrix'); + : super('UiMatrix.Instantiate_Identity_UiMatrix'); @override void run() { @@ -86,7 +86,7 @@ class InstantiateIdentityUiMatrix extends BenchmarkBase { class Instantiate2DTranslationMatrix4 extends BenchmarkBase { Instantiate2DTranslationMatrix4() - : super('UiMatrix.Instantiate_2DTranslation_Matrix4'); + : super('UiMatrix.Instantiate_2DTranslation_Matrix4'); @override void run() { @@ -100,7 +100,7 @@ class Instantiate2DTranslationMatrix4 extends BenchmarkBase { class Instantiate2DTranslationUiMatrix extends BenchmarkBase { Instantiate2DTranslationUiMatrix() - : super('UiMatrix.Instantiate_2DTranslation_UiMatrix'); + : super('UiMatrix.Instantiate_2DTranslation_UiMatrix'); @override void run() { @@ -119,10 +119,11 @@ class InstantiateSimple2DMatrix4 extends BenchmarkBase { void run() { double total = 0; for (int i = 0; i < N; i++) { - total += (Matrix4.identity() - ..translate(0.4, 3.45) - ..scale(1.2, 2.3)) - .storage[0]; + total += + (Matrix4.identity() + ..translate(0.4, 3.45) + ..scale(1.2, 2.3)) + .storage[0]; } sink = total; } @@ -130,7 +131,7 @@ class InstantiateSimple2DMatrix4 extends BenchmarkBase { class InstantiateSimple2DUiMatrix extends BenchmarkBase { InstantiateSimple2DUiMatrix() - : super('UiMatrix.Instantiate_Simple2D_UiMatrix'); + : super('UiMatrix.Instantiate_Simple2D_UiMatrix'); @override void run() { @@ -150,10 +151,11 @@ class InstantiateComplexMatrix4 extends BenchmarkBase { void run() { double total = 0; for (int i = 0; i < N; i++) { - total += (Matrix4.identity() - ..rotateZ(0.1) - ..translate(0.4, 3.45)) - .storage[0]; + total += + (Matrix4.identity() + ..rotateZ(0.1) + ..translate(0.4, 3.45)) + .storage[0]; } sink = total; } @@ -168,14 +170,15 @@ class InstantiateComplexUiMatrix extends BenchmarkBase { for (int i = 0; i < N; i++) { final cosAngle = math.cos(0.1); final sinAngle = math.sin(0.1); - total += UiMatrix.transform2d( - scaleX: cosAngle, - scaleY: cosAngle, - k1: -sinAngle, - k2: sinAngle, - dx: 0.4, - dy: 3.45, - ).scaleX; + total += + UiMatrix.transform2d( + scaleX: cosAngle, + scaleY: cosAngle, + k1: -sinAngle, + k2: sinAngle, + dx: 0.4, + dy: 3.45, + ).scaleX; } sink = total; } @@ -188,7 +191,7 @@ late Matrix4 b4; class MultiplyIdentityByIdentityMatrix4 extends BenchmarkBase { MultiplyIdentityByIdentityMatrix4() - : super('UiMatrix.Multiply_IdentityByIdentity_Matrix4') { + : super('UiMatrix.Multiply_IdentityByIdentity_Matrix4') { a4 = Matrix4.identity(); b4 = Matrix4.identity(); } @@ -205,7 +208,7 @@ class MultiplyIdentityByIdentityMatrix4 extends BenchmarkBase { class MultiplyIdentityByIdentityUiMatrix extends BenchmarkBase { MultiplyIdentityByIdentityUiMatrix() - : super('UiMatrix.Multiply_IdentityByIdentity_UiMatrix') { + : super('UiMatrix.Multiply_IdentityByIdentity_UiMatrix') { a = UiMatrix.identity; b = UiMatrix.identity; } @@ -222,10 +225,11 @@ class MultiplyIdentityByIdentityUiMatrix extends BenchmarkBase { class MultiplySimply2DByIdentityMatrix4 extends BenchmarkBase { MultiplySimply2DByIdentityMatrix4() - : super('UiMatrix.Multiply_Simple2DByIdentity_Matrix4') { - a4 = Matrix4.identity() - ..translate(0.4, 3.45) - ..scale(1.2, 2.3); + : super('UiMatrix.Multiply_Simple2DByIdentity_Matrix4') { + a4 = + Matrix4.identity() + ..translate(0.4, 3.45) + ..scale(1.2, 2.3); b4 = Matrix4.identity(); } @@ -241,7 +245,7 @@ class MultiplySimply2DByIdentityMatrix4 extends BenchmarkBase { class MultiplySimply2DByIdentityUiMatrix extends BenchmarkBase { MultiplySimply2DByIdentityUiMatrix() - : super('UiMatrix.Multiply_Simple2DByIdentity_UiMatrix') { + : super('UiMatrix.Multiply_Simple2DByIdentity_UiMatrix') { a = UiMatrix.simple2d(scaleX: 1.2, scaleY: 2.3, dx: 0.4, dy: 3.45); b = UiMatrix.identity; } @@ -258,13 +262,15 @@ class MultiplySimply2DByIdentityUiMatrix extends BenchmarkBase { class MultiplySimple2DBySimple2DMatrix4 extends BenchmarkBase { MultiplySimple2DBySimple2DMatrix4() - : super('UiMatrix.Multiply_Simple2DBySimple2D_Matrix4') { - a4 = Matrix4.identity() - ..translate(0.4, 3.45) - ..scale(1.2, 2.3); - b4 = Matrix4.identity() - ..translate(0.5, 3.46) - ..scale(1.7, 2.8); + : super('UiMatrix.Multiply_Simple2DBySimple2D_Matrix4') { + a4 = + Matrix4.identity() + ..translate(0.4, 3.45) + ..scale(1.2, 2.3); + b4 = + Matrix4.identity() + ..translate(0.5, 3.46) + ..scale(1.7, 2.8); } @override void run() { @@ -278,7 +284,7 @@ class MultiplySimple2DBySimple2DMatrix4 extends BenchmarkBase { class MultiplySimple2DBySimple2DUiMatrix extends BenchmarkBase { MultiplySimple2DBySimple2DUiMatrix() - : super('UiMatrix.Multiply_Simple2DBySimple2D_UiMatrix') { + : super('UiMatrix.Multiply_Simple2DBySimple2D_UiMatrix') { a = UiMatrix.simple2d(scaleX: 1.2, scaleY: 2.3, dx: 0.4, dy: 3.45); b = UiMatrix.simple2d(scaleX: 1.3, scaleY: 2.4, dx: 0.5, dy: 3.46); } @@ -294,13 +300,15 @@ class MultiplySimple2DBySimple2DUiMatrix extends BenchmarkBase { class MultiplyComplexByComplexMatrix4 extends BenchmarkBase { MultiplyComplexByComplexMatrix4() - : super('UiMatrix.Multiply_ComplexByComplex_Matrix4') { - a4 = Matrix4.identity() - ..rotateZ(0.1) - ..translate(0.4, 3.45); - b4 = Matrix4.identity() - ..rotateZ(0.2) - ..translate(0.3, 3.44); + : super('UiMatrix.Multiply_ComplexByComplex_Matrix4') { + a4 = + Matrix4.identity() + ..rotateZ(0.1) + ..translate(0.4, 3.45); + b4 = + Matrix4.identity() + ..rotateZ(0.2) + ..translate(0.3, 3.44); } @override void run() { @@ -314,7 +322,7 @@ class MultiplyComplexByComplexMatrix4 extends BenchmarkBase { class MultiplyComplexByComplexUiMatrix extends BenchmarkBase { MultiplyComplexByComplexUiMatrix() - : super('UiMatrix.Multiply_ComplexByComplex_UiMatrix') { + : super('UiMatrix.Multiply_ComplexByComplex_UiMatrix') { a = UiMatrix.transform2d( scaleX: math.cos(0.1), scaleY: math.cos(0.1), @@ -344,7 +352,7 @@ class MultiplyComplexByComplexUiMatrix extends BenchmarkBase { class AddIdentityPlusIdentityMatrix4 extends BenchmarkBase { AddIdentityPlusIdentityMatrix4() - : super('UiMatrix.Add_IdentityPlusIdentity_Matrix4') { + : super('UiMatrix.Add_IdentityPlusIdentity_Matrix4') { a4 = Matrix4.identity(); b4 = Matrix4.identity(); } @@ -360,7 +368,7 @@ class AddIdentityPlusIdentityMatrix4 extends BenchmarkBase { class AddIdentityPlusIdentityUiMatrix extends BenchmarkBase { AddIdentityPlusIdentityUiMatrix() - : super('UiMatrix.Add_IdentityPlusIdentity_UiMatrix') { + : super('UiMatrix.Add_IdentityPlusIdentity_UiMatrix') { a = UiMatrix.identity; b = UiMatrix.identity; } @@ -376,10 +384,11 @@ class AddIdentityPlusIdentityUiMatrix extends BenchmarkBase { class AddSimple2DPlusIdentityMatrix4 extends BenchmarkBase { AddSimple2DPlusIdentityMatrix4() - : super('UiMatrix.Add_Simple2DPlusIdentity_Matrix4') { - a4 = Matrix4.identity() - ..translate(0.4, 3.45) - ..scale(1.2, 2.3); + : super('UiMatrix.Add_Simple2DPlusIdentity_Matrix4') { + a4 = + Matrix4.identity() + ..translate(0.4, 3.45) + ..scale(1.2, 2.3); b4 = Matrix4.identity(); } @override @@ -394,7 +403,7 @@ class AddSimple2DPlusIdentityMatrix4 extends BenchmarkBase { class AddSimple2DPlusIdentityUiMatrix extends BenchmarkBase { AddSimple2DPlusIdentityUiMatrix() - : super('UiMatrix.Add_Simple2DPlusIdentity_UiMatrix') { + : super('UiMatrix.Add_Simple2DPlusIdentity_UiMatrix') { a = UiMatrix.simple2d(scaleX: 1.2, scaleY: 2.3, dx: 0.4, dy: 3.45); b = UiMatrix.identity; } @@ -410,13 +419,15 @@ class AddSimple2DPlusIdentityUiMatrix extends BenchmarkBase { class AddSimple2DPlusSimple2DMatrix4 extends BenchmarkBase { AddSimple2DPlusSimple2DMatrix4() - : super('UiMatrix.Add_Simple2DPlusSimple2D_Matrix4') { - a4 = Matrix4.identity() - ..translate(0.4, 3.45) - ..scale(1.2, 2.3); - b4 = Matrix4.identity() - ..translate(0.5, 3.46) - ..scale(1.7, 2.8); + : super('UiMatrix.Add_Simple2DPlusSimple2D_Matrix4') { + a4 = + Matrix4.identity() + ..translate(0.4, 3.45) + ..scale(1.2, 2.3); + b4 = + Matrix4.identity() + ..translate(0.5, 3.46) + ..scale(1.7, 2.8); } @override void run() { @@ -430,7 +441,7 @@ class AddSimple2DPlusSimple2DMatrix4 extends BenchmarkBase { class AddSimple2DPlusSimple2DUiMatrix extends BenchmarkBase { AddSimple2DPlusSimple2DUiMatrix() - : super('UiMatrix.Add_Simple2DPlusSimple2D_UiMatrix') { + : super('UiMatrix.Add_Simple2DPlusSimple2D_UiMatrix') { a = UiMatrix.simple2d(scaleX: 1.2, scaleY: 2.3, dx: 0.4, dy: 3.45); b = UiMatrix.simple2d(scaleX: 1.3, scaleY: 2.4, dx: 0.5, dy: 3.46); } @@ -446,13 +457,15 @@ class AddSimple2DPlusSimple2DUiMatrix extends BenchmarkBase { class AddComplexPlusComplexMatrix4 extends BenchmarkBase { AddComplexPlusComplexMatrix4() - : super('UiMatrix.Add_ComplexPlusComplex_Matrix4') { - a4 = Matrix4.identity() - ..rotateZ(0.1) - ..translate(0.4, 3.45); - b4 = Matrix4.identity() - ..rotateZ(0.2) - ..translate(0.3, 3.44); + : super('UiMatrix.Add_ComplexPlusComplex_Matrix4') { + a4 = + Matrix4.identity() + ..rotateZ(0.1) + ..translate(0.4, 3.45); + b4 = + Matrix4.identity() + ..rotateZ(0.2) + ..translate(0.3, 3.44); } @override void run() { @@ -466,7 +479,7 @@ class AddComplexPlusComplexMatrix4 extends BenchmarkBase { class AddComplexPlusComplexUiMatrix extends BenchmarkBase { AddComplexPlusComplexUiMatrix() - : super('UiMatrix.Add_ComplexPlusComplex_UiMatrix') { + : super('UiMatrix.Add_ComplexPlusComplex_UiMatrix') { a = UiMatrix.transform2d( scaleX: math.cos(0.1), scaleY: math.cos(0.1), @@ -527,9 +540,10 @@ class InversionIdentityUiMatrix extends BenchmarkBase { class InversionSimple2DMatrix4 extends BenchmarkBase { InversionSimple2DMatrix4() : super('UiMatrix.Inversion_Simple2D_Matrix4') { - a4 = Matrix4.identity() - ..translate(0.4, 3.45) - ..scale(1.2, 2.3); + a4 = + Matrix4.identity() + ..translate(0.4, 3.45) + ..scale(1.2, 2.3); } @override @@ -560,9 +574,10 @@ class InversionSimple2DUiMatrix extends BenchmarkBase { class InversionComplexMatrix4 extends BenchmarkBase { InversionComplexMatrix4() : super('UiMatrix.Inversion_Complex_Matrix4') { - a4 = Matrix4.identity() - ..rotateZ(0.1) - ..translate(0.4, 3.45); + a4 = + Matrix4.identity() + ..rotateZ(0.1) + ..translate(0.4, 3.45); } @override @@ -600,7 +615,7 @@ class InversionComplexUiMatrix extends BenchmarkBase { class DeterminantIdentityMatrix4 extends BenchmarkBase { DeterminantIdentityMatrix4() - : super('UiMatrix.Determinant_Identity_Matrix4') { + : super('UiMatrix.Determinant_Identity_Matrix4') { a4 = Matrix4.identity(); } @override @@ -615,7 +630,7 @@ class DeterminantIdentityMatrix4 extends BenchmarkBase { class DeterminantIdentityUiMatrix extends BenchmarkBase { DeterminantIdentityUiMatrix() - : super('UiMatrix.Determinant_Identity_UiMatrix') { + : super('UiMatrix.Determinant_Identity_UiMatrix') { a = UiMatrix.identity; } @override @@ -630,10 +645,11 @@ class DeterminantIdentityUiMatrix extends BenchmarkBase { class DeterminantSimple2DMatrix4 extends BenchmarkBase { DeterminantSimple2DMatrix4() - : super('UiMatrix.Determinant_Simple2D_Matrix4') { - a4 = Matrix4.identity() - ..translate(0.4, 3.45) - ..scale(1.2, 2.3); + : super('UiMatrix.Determinant_Simple2D_Matrix4') { + a4 = + Matrix4.identity() + ..translate(0.4, 3.45) + ..scale(1.2, 2.3); } @override void run() { @@ -647,7 +663,7 @@ class DeterminantSimple2DMatrix4 extends BenchmarkBase { class DeterminantSimple2DUiMatrix extends BenchmarkBase { DeterminantSimple2DUiMatrix() - : super('UiMatrix.Determinant_Simple2D_UiMatrix') { + : super('UiMatrix.Determinant_Simple2D_UiMatrix') { a = UiMatrix.simple2d(scaleX: 1.2, scaleY: 2.3, dx: 0.4, dy: 3.45); } @override @@ -662,9 +678,10 @@ class DeterminantSimple2DUiMatrix extends BenchmarkBase { class DeterminantComplexMatrix4 extends BenchmarkBase { DeterminantComplexMatrix4() : super('UiMatrix.Determinant_Complex_Matrix4') { - a4 = Matrix4.identity() - ..rotateZ(0.1) - ..translate(0.4, 3.45); + a4 = + Matrix4.identity() + ..rotateZ(0.1) + ..translate(0.4, 3.45); } @override void run() { @@ -678,7 +695,7 @@ class DeterminantComplexMatrix4 extends BenchmarkBase { class DeterminantComplexUiMatrix extends BenchmarkBase { DeterminantComplexUiMatrix() - : super('UiMatrix.Determinant_Complex_UiMatrix') { + : super('UiMatrix.Determinant_Complex_UiMatrix') { a = UiMatrix.transform2d( scaleX: math.cos(0.1), scaleY: math.cos(0.1), diff --git a/benchmarks/UiMatrix/dart/uimatrix.dart b/benchmarks/UiMatrix/dart/uimatrix.dart index 02fb2e10410..d4554714e13 100644 --- a/benchmarks/UiMatrix/dart/uimatrix.dart +++ b/benchmarks/UiMatrix/dart/uimatrix.dart @@ -199,12 +199,7 @@ final class UiMatrix { m31 == 0 && m32 == 0 && m33 == 1) { - return UiMatrix.simple2d( - scaleX: m00, - scaleY: m11, - dx: m03, - dy: m13, - ); + return UiMatrix.simple2d(scaleX: m00, scaleY: m11, dx: m03, dy: m13); } return UiMatrix._( @@ -235,11 +230,11 @@ final class UiMatrix { required double m03, required double m13, _MatrixExtension? rest, - }) : _m00 = m00, - _m11 = m11, - _m03 = m03, - _m13 = m13, - _rest = rest; + }) : _m00 = m00, + _m11 = m11, + _m03 = m03, + _m13 = m13, + _rest = rest; final double _m00; final double _m11; @@ -275,7 +270,8 @@ final class UiMatrix { // enable future specializations. _MatrixExtension? rest; if (otherRest != null || selfRest != null) { - rest = (selfRest ?? _MatrixExtension._identityExtension) + + rest = + (selfRest ?? _MatrixExtension._identityExtension) + (otherRest ?? _MatrixExtension._identityExtension); } @@ -315,12 +311,20 @@ final class UiMatrix { ); } else { return _generalMultiply( - this, selfRest, other, _MatrixExtension._identityExtension); + this, + selfRest, + other, + _MatrixExtension._identityExtension, + ); } } else { if (selfRest == null) { return _generalMultiply( - this, _MatrixExtension._identityExtension, other, otherRest); + this, + _MatrixExtension._identityExtension, + other, + otherRest, + ); } else { return _generalMultiply(this, selfRest, other, otherRest); } @@ -401,18 +405,18 @@ final class _MatrixExtension { required double m31, required double m32, required double m33, - }) : _m01 = m01, - _m02 = m02, - _m10 = m10, - _m12 = m12, - _m20 = m20, - _m21 = m21, - _m22 = m22, - _m23 = m23, - _m30 = m30, - _m31 = m31, - _m32 = m32, - _m33 = m33; + }) : _m01 = m01, + _m02 = m02, + _m10 = m10, + _m12 = m12, + _m20 = m20, + _m21 = m21, + _m22 = m22, + _m23 = m23, + _m30 = m30, + _m31 = m31, + _m32 = m32, + _m33 = m33; final double _m01; final double _m02; @@ -463,7 +467,11 @@ final class _MatrixExtension { } UiMatrix _generalMultiply( - UiMatrix m, _MatrixExtension mExt, UiMatrix n, _MatrixExtension nExt) { + UiMatrix m, + _MatrixExtension mExt, + UiMatrix n, + _MatrixExtension nExt, +) { final double m00 = m._m00; final double m01 = mExt._m01; final double m02 = mExt._m02; diff --git a/benchmarks/Utf8Decode/dart/Utf8Decode.dart b/benchmarks/Utf8Decode/dart/Utf8Decode.dart index 5224bbc4413..1cec95b4b0c 100644 --- a/benchmarks/Utf8Decode/dart/Utf8Decode.dart +++ b/benchmarks/Utf8Decode/dart/Utf8Decode.dart @@ -27,9 +27,10 @@ class Utf8Decode extends BenchmarkBase { static String _makeName(String language, int size, bool allowMalformed) { String name = 'Utf8Decode.$language.'; - name += size >= 1000000 - ? '${size ~/ 1000000}M' - : size >= 1000 + name += + size >= 1000000 + ? '${size ~/ 1000000}M' + : size >= 1000 ? '${size ~/ 1000}k' : '$size'; if (allowMalformed) name += '.malformed'; @@ -37,7 +38,7 @@ class Utf8Decode extends BenchmarkBase { } Utf8Decode(this.language, this.text, this.size, this.allowMalformed) - : super(_makeName(language, size, allowMalformed)); + : super(_makeName(language, size, allowMalformed)); @override void setup() { @@ -110,21 +111,14 @@ class Utf8Decode extends BenchmarkBase { } void main(List args) { - const texts = { - 'en': en, - 'da': da, - 'sk': sk, - 'ru': ru, - 'ne': ne, - 'zh': zh, - }; + const texts = {'en': en, 'da': da, 'sk': sk, 'ru': ru, 'ne': ne, 'zh': zh}; final bool testMalformed = args.isNotEmpty && args.first == 'malformed'; final benchmarks = [ // Only benchmark with allowMalformed: false unless specified otherwise. for (bool allowMalformed in [false, if (testMalformed) true]) for (int size in [10, 10000, 10000000]) for (String language in texts.keys) - () => Utf8Decode(language, texts[language]!, size, allowMalformed) + () => Utf8Decode(language, texts[language]!, size, allowMalformed), ]; for (var bm in benchmarks) { diff --git a/benchmarks/Utf8Decode/dart2/Utf8Decode.dart b/benchmarks/Utf8Decode/dart2/Utf8Decode.dart index 4c8ad9ede62..a264f092575 100644 --- a/benchmarks/Utf8Decode/dart2/Utf8Decode.dart +++ b/benchmarks/Utf8Decode/dart2/Utf8Decode.dart @@ -29,9 +29,10 @@ class Utf8Decode extends BenchmarkBase { static String _makeName(String language, int size, bool allowMalformed) { String name = 'Utf8Decode.$language.'; - name += size >= 1000000 - ? '${size ~/ 1000000}M' - : size >= 1000 + name += + size >= 1000000 + ? '${size ~/ 1000000}M' + : size >= 1000 ? '${size ~/ 1000}k' : '$size'; if (allowMalformed) name += '.malformed'; @@ -39,7 +40,7 @@ class Utf8Decode extends BenchmarkBase { } Utf8Decode(this.language, this.text, this.size, this.allowMalformed) - : super(_makeName(language, size, allowMalformed)); + : super(_makeName(language, size, allowMalformed)); @override void setup() { @@ -112,14 +113,7 @@ class Utf8Decode extends BenchmarkBase { } void main(List args) { - const texts = { - 'en': en, - 'da': da, - 'sk': sk, - 'ru': ru, - 'ne': ne, - 'zh': zh, - }; + const texts = {'en': en, 'da': da, 'sk': sk, 'ru': ru, 'ne': ne, 'zh': zh}; final bool testMalformed = args != null && args.isNotEmpty && args.first == 'malformed'; final benchmarks = [ @@ -127,7 +121,7 @@ void main(List args) { for (bool allowMalformed in [false, if (testMalformed) true]) for (int size in [10, 10000, 10000000]) for (String language in texts.keys) - () => Utf8Decode(language, texts[language], size, allowMalformed) + () => Utf8Decode(language, texts[language], size, allowMalformed), ]; for (var bm in benchmarks) { diff --git a/benchmarks/Utf8DecodeComplex/dart/benchmarks.dart b/benchmarks/Utf8DecodeComplex/dart/benchmarks.dart index 90c0150aed3..24a95938acc 100644 --- a/benchmarks/Utf8DecodeComplex/dart/benchmarks.dart +++ b/benchmarks/Utf8DecodeComplex/dart/benchmarks.dart @@ -128,7 +128,7 @@ void check(String result, List sequence) { bytes0tag => targetSize, bytes1tag => 7144, bytes2tag => 5266, - _ => throw 'Unexpected sequence start: ${sequence[0]}' + _ => throw 'Unexpected sequence start: ${sequence[0]}', }; Expect.equals(expectedLength, result.length); } @@ -136,13 +136,16 @@ void check(String result, List sequence) { /// Expands a sequence by repetition and padding to `targetSize` bytes. Uint8List makeSequence(List bytes) { Expect.equals( - 1, - bytes.length.gcd(chunkSize), - 'Bad repeated size (${bytes.length}).' - ' Repeated sequence should be co-prime with chunk size ($chunkSize)' - ' to exercise more UTF-8 boundaries'); - final repeats = - List.filled(targetSize ~/ bytes.length, bytes).expand((byte) => byte); + 1, + bytes.length.gcd(chunkSize), + 'Bad repeated size (${bytes.length}).' + ' Repeated sequence should be co-prime with chunk size ($chunkSize)' + ' to exercise more UTF-8 boundaries', + ); + final repeats = List.filled( + targetSize ~/ bytes.length, + bytes, + ).expand((byte) => byte); final padding = List.filled(targetSize.remainder(bytes.length), 0); // NULs. final sequence = Uint8List.fromList([...repeats, ...padding]); Expect.equals(targetSize, sequence.length); @@ -212,7 +215,8 @@ abstract class ChunkedBase extends Utf8DecodeBenchmarkBase { void run() { late final String result; final byteSink = const Utf8Decoder().startChunkedConversion( - StringConversionSink.withCallback((s) => result = s)); + StringConversionSink.withCallback((s) => result = s), + ); for (final chunk in chunks) { byteSink.add(chunk); @@ -263,11 +267,17 @@ void mainPoly() { Simple('poly.simple.list.1byte.10k', List.of(sequence1)), Simple('poly.simple.list.2byte.10k', List.of(sequence2)), Simple( - 'poly.simple.unmodifiable.ascii.10k', sequence0.asUnmodifiableView()), + 'poly.simple.unmodifiable.ascii.10k', + sequence0.asUnmodifiableView(), + ), Simple( - 'poly.simple.unmodifiable.1byte.10k', sequence1.asUnmodifiableView()), + 'poly.simple.unmodifiable.1byte.10k', + sequence1.asUnmodifiableView(), + ), Simple( - 'poly.simple.unmodifiable.2byte.10k', sequence2.asUnmodifiableView()), + 'poly.simple.unmodifiable.2byte.10k', + sequence2.asUnmodifiableView(), + ), Chunked('poly.chunked.ascii.10k', sequence0), Chunked('poly.chunked.1byte.10k', sequence1), Chunked('poly.chunked.2byte.10k', sequence2), @@ -275,11 +285,17 @@ void mainPoly() { Chunked('poly.chunked.list.1byte.10k', List.of(sequence1)), Chunked('poly.chunked.list.2byte.10k', List.of(sequence2)), ChunkedUnmodifiable( - 'poly.chunked.unmodifiable.ascii.10k', sequence0.asUnmodifiableView()), + 'poly.chunked.unmodifiable.ascii.10k', + sequence0.asUnmodifiableView(), + ), ChunkedUnmodifiable( - 'poly.chunked.unmodifiable.1byte.10k', sequence1.asUnmodifiableView()), + 'poly.chunked.unmodifiable.1byte.10k', + sequence1.asUnmodifiableView(), + ), ChunkedUnmodifiable( - 'poly.chunked.unmodifiable.2byte.10k', sequence2.asUnmodifiableView()), + 'poly.chunked.unmodifiable.2byte.10k', + sequence2.asUnmodifiableView(), + ), ]; runAll(benchmarks); } @@ -314,17 +330,29 @@ void mainMono3() { // Monomorphic: All inputs are unmodifiable `Uint8List`s. final benchmarks = [ Simple( - 'mono.simple.unmodifiable.ascii.10k', sequence0.asUnmodifiableView()), + 'mono.simple.unmodifiable.ascii.10k', + sequence0.asUnmodifiableView(), + ), Simple( - 'mono.simple.unmodifiable.1byte.10k', sequence1.asUnmodifiableView()), + 'mono.simple.unmodifiable.1byte.10k', + sequence1.asUnmodifiableView(), + ), Simple( - 'mono.simple.unmodifiable.2byte.10k', sequence2.asUnmodifiableView()), + 'mono.simple.unmodifiable.2byte.10k', + sequence2.asUnmodifiableView(), + ), ChunkedUnmodifiable( - 'mono.chunked.unmodifiable.ascii.10k', sequence0.asUnmodifiableView()), + 'mono.chunked.unmodifiable.ascii.10k', + sequence0.asUnmodifiableView(), + ), ChunkedUnmodifiable( - 'mono.chunked.unmodifiable.1byte.10k', sequence1.asUnmodifiableView()), + 'mono.chunked.unmodifiable.1byte.10k', + sequence1.asUnmodifiableView(), + ), ChunkedUnmodifiable( - 'mono.chunked.unmodifiable.2byte.10k', sequence2.asUnmodifiableView()), + 'mono.chunked.unmodifiable.2byte.10k', + sequence2.asUnmodifiableView(), + ), ]; runAll(benchmarks); } diff --git a/benchmarks/Utf8Encode/dart/Utf8Encode.dart b/benchmarks/Utf8Encode/dart/Utf8Encode.dart index 9686a9356ec..1dc390760d4 100644 --- a/benchmarks/Utf8Encode/dart/Utf8Encode.dart +++ b/benchmarks/Utf8Encode/dart/Utf8Encode.dart @@ -26,16 +26,17 @@ class Utf8Encode extends BenchmarkBase { static String _makeName(String language, int size) { String name = 'Utf8Encode.$language.'; - name += size >= 1000000 - ? '${size ~/ 1000000}M' - : size >= 1000 + name += + size >= 1000000 + ? '${size ~/ 1000000}M' + : size >= 1000 ? '${size ~/ 1000}k' : '$size'; return name; } Utf8Encode(this.language, this.originalText, this.size) - : super(_makeName(language, size)); + : super(_makeName(language, size)); @override void setup() { @@ -45,8 +46,9 @@ class Utf8Encode extends BenchmarkBase { final int nChunks = (size < nRunes) ? (nRunes / size).floor() : 1; for (int i = 0; i < nChunks; i++) { final offset = i * size; - benchmarkTextChunks - .add(String.fromCharCodes(runes.sublist(offset, offset + size))); + benchmarkTextChunks.add( + String.fromCharCodes(runes.sublist(offset, offset + size)), + ); } } @@ -81,18 +83,11 @@ class Utf8Encode extends BenchmarkBase { } void main(List args) { - const texts = { - 'en': en, - 'da': da, - 'sk': sk, - 'ru': ru, - 'ne': ne, - 'zh': zh, - }; + const texts = {'en': en, 'da': da, 'sk': sk, 'ru': ru, 'ne': ne, 'zh': zh}; final benchmarks = [ for (int size in [10, 10000, 10000000]) for (String language in texts.keys) - () => Utf8Encode(language, texts[language]!, size) + () => Utf8Encode(language, texts[language]!, size), ]; for (var bm in benchmarks) { diff --git a/benchmarks/Utf8Encode/dart2/Utf8Encode.dart b/benchmarks/Utf8Encode/dart2/Utf8Encode.dart index 61851ffa32e..c074671520e 100644 --- a/benchmarks/Utf8Encode/dart2/Utf8Encode.dart +++ b/benchmarks/Utf8Encode/dart2/Utf8Encode.dart @@ -28,16 +28,17 @@ class Utf8Encode extends BenchmarkBase { static String _makeName(String language, int size) { String name = 'Utf8Encode.$language.'; - name += size >= 1000000 - ? '${size ~/ 1000000}M' - : size >= 1000 + name += + size >= 1000000 + ? '${size ~/ 1000000}M' + : size >= 1000 ? '${size ~/ 1000}k' : '$size'; return name; } Utf8Encode(this.language, this.originalText, this.size) - : super(_makeName(language, size)); + : super(_makeName(language, size)); @override void setup() { @@ -48,8 +49,9 @@ class Utf8Encode extends BenchmarkBase { benchmarkTextChunks = List.filled(nChunks, null); for (int i = 0; i < nChunks; i++) { final offset = i * size; - benchmarkTextChunks[i] = - String.fromCharCodes(runes.sublist(offset, offset + size)); + benchmarkTextChunks[i] = String.fromCharCodes( + runes.sublist(offset, offset + size), + ); } } @@ -84,18 +86,11 @@ class Utf8Encode extends BenchmarkBase { } void main(List args) { - const texts = { - 'en': en, - 'da': da, - 'sk': sk, - 'ru': ru, - 'ne': ne, - 'zh': zh, - }; + const texts = {'en': en, 'da': da, 'sk': sk, 'ru': ru, 'ne': ne, 'zh': zh}; final benchmarks = [ for (int size in [10, 10000, 10000000]) for (String language in texts.keys) - () => Utf8Encode(language, texts[language], size) + () => Utf8Encode(language, texts[language], size), ]; for (var bm in benchmarks) { diff --git a/benchmarks/WasmDataTransfer/dart/WasmDataTransfer.dart b/benchmarks/WasmDataTransfer/dart/WasmDataTransfer.dart index fc18339c01d..cfef2e39fdd 100644 --- a/benchmarks/WasmDataTransfer/dart/WasmDataTransfer.dart +++ b/benchmarks/WasmDataTransfer/dart/WasmDataTransfer.dart @@ -65,7 +65,7 @@ class WasmDataTransferFromBrowserString extends Benchmark { final JSString jsonString; WasmDataTransferFromBrowserString(this.jsonString, String subName) - : super('WasmDataTransfer.FromBrowserString.$subName'); + : super('WasmDataTransfer.FromBrowserString.$subName'); @override void run() { @@ -86,7 +86,7 @@ class WasmDataTransferFromBrowserBytes extends Benchmark { final JSUint8Array bytes; WasmDataTransferFromBrowserBytes(this.bytes, String subName) - : super('WasmDataTransfer.FromBrowserBytes.$subName'); + : super('WasmDataTransfer.FromBrowserBytes.$subName'); @override void run() { @@ -98,7 +98,7 @@ class WasmDataTransferToBrowserString extends Benchmark { final String string; WasmDataTransferToBrowserString(this.string, String subName) - : super('WasmDataTransfer.ToBrowserString.$subName'); + : super('WasmDataTransfer.ToBrowserString.$subName'); @override void run() { @@ -110,7 +110,7 @@ class WasmDataTransferToBrowserBytes extends Benchmark { final Uint8List bytes; WasmDataTransferToBrowserBytes(this.bytes, String subName) - : super('WasmDataTransfer.ToBrowserBytes.$subName'); + : super('WasmDataTransfer.ToBrowserBytes.$subName'); @override void run() {