Format benchmarks/.
Change-Id: I1362ada67a02b0ed352612fc29c727e94d8cd254 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394901 Commit-Queue: Daco Harkes <dacoharkes@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com> Reviewed-by: Daco Harkes <dacoharkes@google.com>
This commit is contained in:
committed by
Commit Queue
parent
54b3ca9ea0
commit
e4c8b49dcc
@@ -11,8 +11,10 @@ import 'package:benchmark_harness/benchmark_harness.dart';
|
||||
|
||||
class MockClass {
|
||||
static final String str = "${int.parse('42')}";
|
||||
static final List<int> list =
|
||||
List<int>.filled(int.parse('3'), int.parse('42'));
|
||||
static final List<int> list = List<int>.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<int> a1, String a2, List<int> a3, String a4,
|
||||
List<int> a5, String a6, List<int> a7) =>
|
||||
void use8(
|
||||
String a0,
|
||||
List<int> a1,
|
||||
String a2,
|
||||
List<int> a3,
|
||||
String a4,
|
||||
List<int> a5,
|
||||
String a6,
|
||||
List<int> a7,
|
||||
) =>
|
||||
a0.length +
|
||||
a1.length +
|
||||
a2.length +
|
||||
@@ -310,7 +320,7 @@ Future<void> main() async {
|
||||
LiveInt1(),
|
||||
LiveInt4(),
|
||||
LiveObj2Int2(),
|
||||
LiveObj4Int4()
|
||||
LiveObj4Int4(),
|
||||
];
|
||||
for (final bench in benchmarks) {
|
||||
await bench.report();
|
||||
|
||||
@@ -13,8 +13,10 @@ import 'package:benchmark_harness/benchmark_harness.dart';
|
||||
|
||||
class MockClass {
|
||||
static final String str = "${int.parse('42')}";
|
||||
static final List<int> list =
|
||||
List<int>.filled(int.parse('3'), int.parse('42'));
|
||||
static final List<int> list = List<int>.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<int> a1, String a2, List<int> a3, String a4,
|
||||
List<int> a5, String a6, List<int> a7) =>
|
||||
void use8(
|
||||
String a0,
|
||||
List<int> a1,
|
||||
String a2,
|
||||
List<int> a3,
|
||||
String a4,
|
||||
List<int> a5,
|
||||
String a6,
|
||||
List<int> a7,
|
||||
) =>
|
||||
a0.length +
|
||||
a1.length +
|
||||
a2.length +
|
||||
@@ -299,7 +309,7 @@ Future<void> main() async {
|
||||
LiveInt1(),
|
||||
LiveInt4(),
|
||||
LiveObj2Int2(),
|
||||
LiveObj4Int4()
|
||||
LiveObj4Int4(),
|
||||
];
|
||||
for (final bench in benchmarks) {
|
||||
await bench.report();
|
||||
|
||||
@@ -31,8 +31,8 @@ const requiredDigits = 11106;
|
||||
class Benchmark extends BenchmarkBase {
|
||||
final List<String> strings;
|
||||
Benchmark(String name, int bits, {bool forInt = false})
|
||||
: strings = generateStrings(bits, forInt),
|
||||
super(name);
|
||||
: strings = generateStrings(bits, forInt),
|
||||
super(name);
|
||||
|
||||
static List<String> generateStrings(int bits, bool forInt) {
|
||||
final List<String> 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());
|
||||
}
|
||||
|
||||
@@ -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; }');
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ const requiredDigits = 11106;
|
||||
class Benchmark extends BenchmarkBase {
|
||||
final List<String> strings;
|
||||
Benchmark(String name, int bits, {bool forInt = false})
|
||||
: strings = generateStrings(bits, forInt),
|
||||
super(name);
|
||||
: strings = generateStrings(bits, forInt),
|
||||
super(name);
|
||||
|
||||
static List<String> generateStrings(int bits, bool forInt) {
|
||||
final List<String> 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());
|
||||
}
|
||||
|
||||
@@ -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; }');
|
||||
}
|
||||
|
||||
|
||||
@@ -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<int> performAwaitCallsClosureTargetPolymorphic(
|
||||
FutureOr<int> Function(int) fun) async {
|
||||
FutureOr<int> Function(int) fun,
|
||||
) async {
|
||||
int sum = 0;
|
||||
for (int i = 0; i < iterationLimitAsync; ++i) {
|
||||
sum += await fun(i);
|
||||
@@ -119,7 +147,8 @@ Future<int> performAwaitCallsClosureTargetPolymorphic(
|
||||
@pragma('wasm:never-inline')
|
||||
@pragma('dart2js:noInline')
|
||||
Future<int> 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<int> performAwaitAsyncCallsInstanceTargetPolymorphic(
|
||||
@pragma('wasm:never-inline')
|
||||
@pragma('dart2js:noInline')
|
||||
Future<int> 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<int> performAwaitFutureCallsInstanceTargetPolymorphic(
|
||||
@pragma('wasm:never-inline')
|
||||
@pragma('dart2js:noInline')
|
||||
Future<int> 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<int> performAwaitFutureOrCalls() async {
|
||||
@pragma('wasm:never-inline')
|
||||
@pragma('dart2js:noInline')
|
||||
Future<int> performAwaitAsyncCallsInstanceTargetPolymorphicManyAwaits(
|
||||
Target t) async {
|
||||
Target t,
|
||||
) async {
|
||||
int sum = 0;
|
||||
int i = 0;
|
||||
|
||||
@@ -295,7 +327,8 @@ Future<int> performAwaitAsyncCallsInstanceTargetPolymorphicManyAwaits(
|
||||
@pragma('wasm:never-inline')
|
||||
@pragma('dart2js:noInline')
|
||||
Future<int> performAwaitForIterationPolymorphic(
|
||||
Stream<int> Function(int) fun) async {
|
||||
Stream<int> Function(int) fun,
|
||||
) async {
|
||||
int sum = 0;
|
||||
await for (int value in fun(iterationLimitAsync)) {
|
||||
sum += value;
|
||||
|
||||
@@ -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<int> performAwaitCallsClosureTargetPolymorphic(
|
||||
FutureOr<int> Function(int) fun) async {
|
||||
FutureOr<int> Function(int) fun,
|
||||
) async {
|
||||
int sum = 0;
|
||||
for (int i = 0; i < iterationLimitAsync; ++i) {
|
||||
sum += await fun(i);
|
||||
@@ -119,7 +147,8 @@ Future<int> performAwaitCallsClosureTargetPolymorphic(
|
||||
@pragma('vm:never-inline')
|
||||
@pragma('dart2js:noInline')
|
||||
Future<int> 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<int> performAwaitAsyncCallsInstanceTargetPolymorphic(
|
||||
@pragma('vm:never-inline')
|
||||
@pragma('dart2js:noInline')
|
||||
Future<int> 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<int> performAwaitFutureCallsInstanceTargetPolymorphic(
|
||||
@pragma('vm:never-inline')
|
||||
@pragma('dart2js:noInline')
|
||||
Future<int> 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<int> performAwaitFutureOrCalls() async {
|
||||
@pragma('vm:never-inline')
|
||||
@pragma('dart2js:noInline')
|
||||
Future<int> performAwaitAsyncCallsInstanceTargetPolymorphicManyAwaits(
|
||||
Target t) async {
|
||||
Target t,
|
||||
) async {
|
||||
int sum = 0;
|
||||
int i = 0;
|
||||
|
||||
@@ -288,7 +320,8 @@ Future<int> performAwaitAsyncCallsInstanceTargetPolymorphicManyAwaits(
|
||||
@pragma('vm:never-inline')
|
||||
@pragma('dart2js:noInline')
|
||||
Future<int> performAwaitForIterationPolymorphic(
|
||||
Stream<int> Function(int) fun) async {
|
||||
Stream<int> Function(int) fun,
|
||||
) async {
|
||||
int sum = 0;
|
||||
await for (int value in fun(iterationLimitAsync)) {
|
||||
sum += value;
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -16,8 +16,10 @@ Future<void> 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);
|
||||
|
||||
@@ -14,7 +14,9 @@ import 'dart:typed_data';
|
||||
///
|
||||
/// Runs [numberOfTicks] times before completing with [EventLoopLatencyStats].
|
||||
Future<EventLoopLatencyStats> measureEventLoopLatency(
|
||||
Duration tickDuration, int numberOfTicks) {
|
||||
Duration tickDuration,
|
||||
int numberOfTicks,
|
||||
) {
|
||||
final completer = Completer<EventLoopLatencyStats>();
|
||||
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,10 @@ Future<void> 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);
|
||||
|
||||
@@ -16,7 +16,9 @@ import 'dart:typed_data';
|
||||
///
|
||||
/// Runs [numberOfTicks] times before completing with [EventLoopLatencyStats].
|
||||
Future<EventLoopLatencyStats> measureEventLoopLatency(
|
||||
Duration tickDuration, int numberOfTicks) {
|
||||
Duration tickDuration,
|
||||
int numberOfTicks,
|
||||
) {
|
||||
final completer = Completer<EventLoopLatencyStats>();
|
||||
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,10 @@ Future<void> 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);
|
||||
|
||||
@@ -14,7 +14,9 @@ import 'dart:typed_data';
|
||||
///
|
||||
/// Runs [numberOfTicks] times before completing with [EventLoopLatencyStats].
|
||||
Future<EventLoopLatencyStats> measureEventLoopLatency(
|
||||
Duration tickDuration, int numberOfTicks) {
|
||||
Duration tickDuration,
|
||||
int numberOfTicks,
|
||||
) {
|
||||
final completer = Completer<EventLoopLatencyStats>();
|
||||
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -16,7 +16,9 @@ import 'dart:typed_data';
|
||||
///
|
||||
/// Runs [numberOfTicks] times before completing with [EventLoopLatencyStats].
|
||||
Future<EventLoopLatencyStats> measureEventLoopLatency(
|
||||
Duration tickDuration, int numberOfTicks) {
|
||||
Duration tickDuration,
|
||||
int numberOfTicks,
|
||||
) {
|
||||
final completer = Completer<EventLoopLatencyStats>();
|
||||
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,10 @@ Future<void> 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);
|
||||
|
||||
@@ -14,7 +14,9 @@ import 'dart:typed_data';
|
||||
///
|
||||
/// Runs [numberOfTicks] times before completing with [EventLoopLatencyStats].
|
||||
Future<EventLoopLatencyStats> measureEventLoopLatency(
|
||||
Duration tickDuration, int numberOfTicks) {
|
||||
Duration tickDuration,
|
||||
int numberOfTicks,
|
||||
) {
|
||||
final completer = Completer<EventLoopLatencyStats>();
|
||||
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -16,7 +16,9 @@ import 'dart:typed_data';
|
||||
///
|
||||
/// Runs [numberOfTicks] times before completing with [EventLoopLatencyStats].
|
||||
Future<EventLoopLatencyStats> measureEventLoopLatency(
|
||||
Duration tickDuration, int numberOfTicks) {
|
||||
Duration tickDuration,
|
||||
int numberOfTicks,
|
||||
) {
|
||||
final completer = Completer<EventLoopLatencyStats>();
|
||||
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,9 +40,7 @@ class FromPointerInt8 extends BenchmarkBase {
|
||||
//
|
||||
|
||||
void main(List<String> args) {
|
||||
final benchmarks = [
|
||||
FromPointerInt8.new,
|
||||
];
|
||||
final benchmarks = [FromPointerInt8.new];
|
||||
|
||||
final filter = args.firstOrNull;
|
||||
for (var constructor in benchmarks) {
|
||||
|
||||
@@ -139,10 +139,7 @@ class DigestDartMemory extends BenchmarkBase {
|
||||
//
|
||||
|
||||
void main(List<String> args) {
|
||||
final benchmarks = [
|
||||
DigestCMemory.new,
|
||||
DigestDartMemory.new,
|
||||
];
|
||||
final benchmarks = [DigestCMemory.new, DigestDartMemory.new];
|
||||
|
||||
final filter = args.firstOrNull;
|
||||
for (var constructor in benchmarks) {
|
||||
|
||||
@@ -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<EVP_MD> Function() EVP_sha512 =
|
||||
ssl.lookupFunction<Pointer<EVP_MD> Function(), Pointer<EVP_MD> Function()>(
|
||||
'EVP_sha512');
|
||||
final Pointer<EVP_MD> Function() EVP_sha512 = ssl
|
||||
.lookupFunction<Pointer<EVP_MD> Function(), Pointer<EVP_MD> 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<EVP_MD> Function() EVP_sha512 =
|
||||
/// EVP_MD_CTX *EVP_MD_CTX_new(void);
|
||||
/// ```
|
||||
final Pointer<EVP_MD_CTX> Function() EVP_MD_CTX_new = ssl.lookupFunction<
|
||||
Pointer<EVP_MD_CTX> Function(),
|
||||
Pointer<EVP_MD_CTX> Function()>('EVP_MD_CTX_new');
|
||||
Pointer<EVP_MD_CTX> Function(),
|
||||
Pointer<EVP_MD_CTX> 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<EVP_MD_CTX> Function() EVP_MD_CTX_new = ssl.lookupFunction<
|
||||
/// void EVP_MD_CTX_free(EVP_MD_CTX *ctx);
|
||||
/// ```
|
||||
final void Function(Pointer<EVP_MD_CTX>) EVP_MD_CTX_free = ssl.lookupFunction<
|
||||
Void Function(Pointer<EVP_MD_CTX>),
|
||||
void Function(Pointer<EVP_MD_CTX>)>('EVP_MD_CTX_free');
|
||||
Void Function(Pointer<EVP_MD_CTX>),
|
||||
void Function(Pointer<EVP_MD_CTX>)
|
||||
>('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>) EVP_MD_CTX_free = ssl.lookupFunction<
|
||||
/// ```c
|
||||
/// int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
|
||||
/// ```
|
||||
final int Function(Pointer<EVP_MD_CTX>, Pointer<EVP_MD>) EVP_DigestInit =
|
||||
ssl.lookupFunction<Int32 Function(Pointer<EVP_MD_CTX>, Pointer<EVP_MD>),
|
||||
int Function(Pointer<EVP_MD_CTX>, Pointer<EVP_MD>)>('EVP_DigestInit');
|
||||
final int Function(Pointer<EVP_MD_CTX>, Pointer<EVP_MD>) EVP_DigestInit = ssl
|
||||
.lookupFunction<
|
||||
Int32 Function(Pointer<EVP_MD_CTX>, Pointer<EVP_MD>),
|
||||
int Function(Pointer<EVP_MD_CTX>, Pointer<EVP_MD>)
|
||||
>('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<EVP_MD_CTX>, Pointer<EVP_MD>) EVP_DigestInit =
|
||||
/// ```
|
||||
final int Function(Pointer<EVP_MD_CTX>, Pointer<Data>, int) EVP_DigestUpdate =
|
||||
ssl.lookupFunction<
|
||||
Int32 Function(Pointer<EVP_MD_CTX>, Pointer<Data>, IntPtr),
|
||||
int Function(
|
||||
Pointer<EVP_MD_CTX>, Pointer<Data>, int)>('EVP_DigestUpdate');
|
||||
Int32 Function(Pointer<EVP_MD_CTX>, Pointer<Data>, IntPtr),
|
||||
int Function(Pointer<EVP_MD_CTX>, Pointer<Data>, 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<EVP_MD_CTX>, Pointer<Data>, int) EVP_DigestUpdate =
|
||||
/// unsigned int *out_size);
|
||||
/// ```
|
||||
final int Function(Pointer<EVP_MD_CTX>, Pointer<Bytes>, Pointer<Uint32>)
|
||||
EVP_DigestFinal = ssl.lookupFunction<
|
||||
Int32 Function(Pointer<EVP_MD_CTX>, Pointer<Bytes>, Pointer<Uint32>),
|
||||
int Function(Pointer<EVP_MD_CTX>, Pointer<Bytes>,
|
||||
Pointer<Uint32>)>('EVP_DigestFinal');
|
||||
EVP_DigestFinal = ssl.lookupFunction<
|
||||
Int32 Function(Pointer<EVP_MD_CTX>, Pointer<Bytes>, Pointer<Uint32>),
|
||||
int Function(Pointer<EVP_MD_CTX>, Pointer<Bytes>, Pointer<Uint32>)
|
||||
>('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<EVP_MD_CTX>, Pointer<Bytes>, Pointer<Uint32>)
|
||||
/// size_t EVP_MD_CTX_size(const EVP_MD_CTX *ctx);
|
||||
/// ```
|
||||
final int Function(Pointer<EVP_MD_CTX>) EVP_MD_CTX_size = ssl.lookupFunction<
|
||||
IntPtr Function(Pointer<EVP_MD_CTX>),
|
||||
int Function(Pointer<EVP_MD_CTX>)>('EVP_MD_CTX_size');
|
||||
IntPtr Function(Pointer<EVP_MD_CTX>),
|
||||
int Function(Pointer<EVP_MD_CTX>)
|
||||
>('EVP_MD_CTX_size');
|
||||
|
||||
@@ -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<NativeFunction1Int64,
|
||||
Function1int>('Function1Int64', isLeaf: true)
|
||||
: ffiTestFunctions.lookupFunction<NativeFunction1Int64,
|
||||
Function1int>('Function1Int64', isLeaf: false),
|
||||
super('FfiCall.Int64Mintx01', isLeaf: isLeaf);
|
||||
: f =
|
||||
isLeaf
|
||||
? ffiTestFunctions
|
||||
.lookupFunction<NativeFunction1Int64, Function1int>(
|
||||
'Function1Int64',
|
||||
isLeaf: true,
|
||||
)
|
||||
: ffiTestFunctions
|
||||
.lookupFunction<NativeFunction1Int64, Function1int>(
|
||||
'Function1Int64',
|
||||
isLeaf: false,
|
||||
),
|
||||
super('FfiCall.Int64Mintx01', isLeaf: isLeaf);
|
||||
|
||||
@override
|
||||
void run() {
|
||||
@@ -85,8 +94,10 @@ class Int64Mintx01 extends FfiBenchmarkBase {
|
||||
void main(List<String> 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,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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<Pointer<Void> Function(Pointer<Char>, Int)>()
|
||||
external Pointer<Void> dlopen(Pointer<Char> 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;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -82,8 +82,12 @@ part of 'FfiCall.dart';
|
||||
|
||||
''';
|
||||
|
||||
void generateTypedefs(StringBuffer buffer, String namePrefix,
|
||||
List<String> types, List<int> numbers) {
|
||||
void generateTypedefs(
|
||||
StringBuffer buffer,
|
||||
String namePrefix,
|
||||
List<String> types,
|
||||
List<int> 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<String> 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<String> 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<double> 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<String> types) {
|
||||
final String dartTypeName = toIdentifier(dartType);
|
||||
for (int number in generateFor[type]!) {
|
||||
final String name = '${typeName}x${'$number'.padLeft(2, '0')}';
|
||||
final List<String> 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<String> 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<String> 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)) {
|
||||
|
||||
@@ -92,7 +92,10 @@ void doStoreDouble(Pointer<Double> pointer, int length) {
|
||||
}
|
||||
|
||||
void doStorePointer(
|
||||
Pointer<Pointer<Int8>> pointer, int length, Pointer<Int8> data) {
|
||||
Pointer<Pointer<Int8>> pointer,
|
||||
int length,
|
||||
Pointer<Int8> data,
|
||||
) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
pointer[i] = data;
|
||||
}
|
||||
|
||||
@@ -69,9 +69,7 @@ class FieldLoadStore extends BenchmarkBase {
|
||||
//
|
||||
|
||||
void main(List<String> args) {
|
||||
final benchmarks = [
|
||||
FieldLoadStore.new,
|
||||
];
|
||||
final benchmarks = [FieldLoadStore.new];
|
||||
|
||||
final filter = args.firstOrNull;
|
||||
for (var constructor in benchmarks) {
|
||||
|
||||
@@ -71,9 +71,7 @@ class FieldLoadStore extends BenchmarkBase {
|
||||
//
|
||||
|
||||
void main() {
|
||||
final benchmarks = [
|
||||
() => FieldLoadStore(),
|
||||
];
|
||||
final benchmarks = [() => FieldLoadStore()];
|
||||
for (final benchmark in benchmarks) {
|
||||
benchmark().report();
|
||||
}
|
||||
|
||||
@@ -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<String> args) {
|
||||
final results = argParser.parse(args);
|
||||
|
||||
@@ -15,12 +15,7 @@ Future<void> 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
|
||||
|
||||
@@ -83,8 +83,10 @@ class BenchmarkAlternatingSizedAdd extends AsyncBenchmarkBase {
|
||||
@override
|
||||
Future<void> 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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<int>()..addAll(randomList)),
|
||||
'IntegerSetLookup.HashSet_Random',
|
||||
HashSet<int>()..addAll(randomList),
|
||||
),
|
||||
];
|
||||
for (final benchmark in benchmarks) {
|
||||
benchmark().report();
|
||||
|
||||
@@ -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<int>()..addAll(randomList)),
|
||||
"IntegerSetLookup.HashSet_Random",
|
||||
HashSet<int>()..addAll(randomList),
|
||||
),
|
||||
];
|
||||
for (final benchmark in benchmarks) {
|
||||
benchmark().report();
|
||||
|
||||
@@ -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<void> run() async {
|
||||
@@ -52,11 +54,13 @@ class SendReceiveHelper {
|
||||
port = ReceivePort();
|
||||
inbox = StreamIterator<dynamic>(port);
|
||||
workerCompleted = Completer<bool>();
|
||||
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<SizeName> sizes = <SizeName>[
|
||||
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<void> 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<void> run() async {
|
||||
@@ -55,11 +57,13 @@ class SendReceiveHelper {
|
||||
port = ReceivePort();
|
||||
inbox = StreamIterator<dynamic>(port);
|
||||
workerCompleted = Completer<bool>();
|
||||
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<SizeName> sizes = <SizeName>[
|
||||
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<void> 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<void> report() async {
|
||||
final stopwatch = Stopwatch()..start();
|
||||
@@ -63,9 +65,12 @@ Future<Map> 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<void> 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<void> main() async {
|
||||
for (final config in configs) {
|
||||
for (final iterations in <int>[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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<void> report() async {
|
||||
final stopwatch = Stopwatch()..start();
|
||||
@@ -66,9 +68,12 @@ Future<Map> 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<void> 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<void> main() async {
|
||||
for (final config in configs) {
|
||||
for (final iterations in <int>[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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,11 @@ class SendReceiveHelper {
|
||||
final port = ReceivePort();
|
||||
inbox = StreamIterator<dynamic>(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<void> isolate(SendPort sendPort) async {
|
||||
|
||||
Future<void> 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();
|
||||
}
|
||||
|
||||
@@ -11,13 +11,16 @@ import 'dart:isolate';
|
||||
import 'latency.dart';
|
||||
|
||||
Future<void> 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 = <dynamic>[];
|
||||
|
||||
@@ -13,8 +13,10 @@ import 'dart:typed_data';
|
||||
///
|
||||
/// Runs [numberOfTicks] times before completing with [EventLoopLatencyStats].
|
||||
Future<EventLoopLatencyStats> measureEventLoopLatency(
|
||||
Duration tickDuration, int numberOfTicks,
|
||||
{void Function()? work}) {
|
||||
Duration tickDuration,
|
||||
int numberOfTicks, {
|
||||
void Function()? work,
|
||||
}) {
|
||||
final completer = Completer<EventLoopLatencyStats>();
|
||||
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 = <dynamic>[];
|
||||
|
||||
@@ -16,8 +16,10 @@ import 'dart:typed_data';
|
||||
///
|
||||
/// Runs [numberOfTicks] times before completing with [EventLoopLatencyStats].
|
||||
Future<EventLoopLatencyStats> measureEventLoopLatency(
|
||||
Duration tickDuration, int numberOfTicks,
|
||||
{void Function() work}) {
|
||||
Duration tickDuration,
|
||||
int numberOfTicks, {
|
||||
void Function() work,
|
||||
}) {
|
||||
final completer = Completer<EventLoopLatencyStats>();
|
||||
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,15 +15,17 @@ class SpawnLatency {
|
||||
final completerResult = Completer();
|
||||
final receivePort = ReceivePort()..listen(completerResult.complete);
|
||||
final isolateExitedCompleter = Completer<DateTime>();
|
||||
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<AggregatedResultMessageLatency> 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<void> isolateCompiler(StartMessageLatency start) async {
|
||||
final timeRunningCodeUs = DateTime.now();
|
||||
await runZoned(
|
||||
() => gen_kernel.compile(<String>[
|
||||
'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(<String>[
|
||||
'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<void> main() async {
|
||||
|
||||
@@ -19,15 +19,17 @@ class SpawnLatency {
|
||||
final completerResult = Completer();
|
||||
final receivePort = ReceivePort()..listen(completerResult.complete);
|
||||
final isolateExitedCompleter = Completer<DateTime>();
|
||||
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<AggregatedResultMessageLatency> 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<void> isolateCompiler(StartMessageLatency start) async {
|
||||
final timeRunningCodeUs = DateTime.now();
|
||||
await runZoned(
|
||||
() => dart2js_main.internalMain(<String>[
|
||||
'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(<String>[
|
||||
'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<void> main() async {
|
||||
|
||||
@@ -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<void> isolateCompiler(StartMessage startMessage) async {
|
||||
await iterator.moveNext();
|
||||
|
||||
await runZoned(
|
||||
() => gen_kernel.compile(<String>[
|
||||
'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(<String>[
|
||||
'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');
|
||||
|
||||
@@ -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<void> isolateCompiler(StartMessage startMessage) async {
|
||||
await iterator.moveNext();
|
||||
|
||||
await runZoned(
|
||||
() => dart2js_main.internalMain(<String>[
|
||||
'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(<String>[
|
||||
'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');
|
||||
|
||||
@@ -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<Iterable> 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<int> _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<int> _list1;
|
||||
final List<int> _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<int> _list1;
|
||||
final List<int> _list2;
|
||||
@@ -458,12 +458,13 @@ List<Thing<Iterable<Comparable>>> generateThingList(int n) {
|
||||
}
|
||||
|
||||
Map<Thing<Iterable<Comparable>>, Thing<Iterable<Comparable>>> generateThingMap(
|
||||
int n) {
|
||||
int n,
|
||||
) {
|
||||
return Map.fromIterables(generateThingList(n), generateThingList(n));
|
||||
}
|
||||
|
||||
Map<Thing<Iterable<Comparable>>, Thing<Iterable<Comparable>>>
|
||||
generateThingHashMap(int n) {
|
||||
generateThingHashMap(int n) {
|
||||
return HashMap.fromIterables(generateThingList(n), generateThingList(n));
|
||||
}
|
||||
|
||||
@@ -484,10 +485,12 @@ Map<int, int> 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<String> commandLineArguments) {
|
||||
BenchmarkListIntGrowable(size),
|
||||
BenchmarkListIntSystem1(size),
|
||||
BenchmarkListIntSystem2(size),
|
||||
Benchmark('List.int.growable', size,
|
||||
(n) => List<int>.of(UpTo(n), growable: true)),
|
||||
Benchmark('List.int.fixed', size,
|
||||
(n) => List<int>.of(UpTo(n), growable: false)),
|
||||
Benchmark('List.int.unmodifiable', size,
|
||||
(n) => List<int>.unmodifiable(UpTo(n))),
|
||||
Benchmark(
|
||||
'List.int.growable',
|
||||
size,
|
||||
(n) => List<int>.of(UpTo(n), growable: true),
|
||||
),
|
||||
Benchmark(
|
||||
'List.int.fixed',
|
||||
size,
|
||||
(n) => List<int>.of(UpTo(n), growable: false),
|
||||
),
|
||||
Benchmark(
|
||||
'List.int.unmodifiable',
|
||||
size,
|
||||
(n) => List<int>.unmodifiable(UpTo(n)),
|
||||
),
|
||||
// ---
|
||||
Benchmark('List.Hard.growable', size, generateThingList),
|
||||
// ---
|
||||
@@ -566,33 +578,63 @@ void main(List<String> 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<int, int>.fromIterables(UpTo(n), UpTo(n)).keys),
|
||||
Benchmark('HashMap.int.values', size,
|
||||
(n) => HashMap<int, int>.fromIterables(UpTo(n), UpTo(n)).values),
|
||||
Benchmark('HashMap.int.entries', size,
|
||||
(n) => HashMap<int, int>.fromIterables(UpTo(n), UpTo(n)).entries),
|
||||
Benchmark(
|
||||
'HashMap.int.keys',
|
||||
size,
|
||||
(n) => HashMap<int, int>.fromIterables(UpTo(n), UpTo(n)).keys,
|
||||
),
|
||||
Benchmark(
|
||||
'HashMap.int.values',
|
||||
size,
|
||||
(n) => HashMap<int, int>.fromIterables(UpTo(n), UpTo(n)).values,
|
||||
),
|
||||
Benchmark(
|
||||
'HashMap.int.entries',
|
||||
size,
|
||||
(n) => HashMap<int, int>.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,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ const Map<int, Map<int, int>> constMapIntIntTable = {
|
||||
0: constMapIntInt0,
|
||||
1: constMapIntInt1,
|
||||
2: constMapIntInt2,
|
||||
100: constMapIntInt100
|
||||
100: constMapIntInt100,
|
||||
};
|
||||
|
||||
const Map<int, int> constMapIntInt0 = {};
|
||||
@@ -127,14 +127,14 @@ const Map<int, int> constMapIntInt100 = {
|
||||
96: 96,
|
||||
97: 97,
|
||||
98: 98,
|
||||
99: 99
|
||||
99: 99,
|
||||
};
|
||||
|
||||
const Map<int, Set<int>> constSetOfIntTable = {
|
||||
0: constSetOfInt0,
|
||||
1: constSetOfInt1,
|
||||
2: constSetOfInt2,
|
||||
100: constSetOfInt100
|
||||
100: constSetOfInt100,
|
||||
};
|
||||
|
||||
const Set<int> constSetOfInt0 = {};
|
||||
@@ -150,14 +150,14 @@ const Set<int> 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<int, List<int>> constListOfIntTable = {
|
||||
0: constListOfInt0,
|
||||
1: constListOfInt1,
|
||||
2: constListOfInt2,
|
||||
100: constListOfInt100
|
||||
100: constListOfInt100,
|
||||
};
|
||||
|
||||
const List<int> constListOfInt0 = [];
|
||||
@@ -173,5 +173,5 @@ const List<int> 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],
|
||||
];
|
||||
|
||||
@@ -31,7 +31,7 @@ class Benchmark extends BenchmarkBase {
|
||||
final List<Iterable<num>> 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<int>(0, (sum, iterable) => sum + iterable.length);
|
||||
totalLength += variants.fold<int>(
|
||||
0,
|
||||
(sum, iterable) => sum + iterable.length,
|
||||
);
|
||||
}
|
||||
|
||||
// Sanity checks.
|
||||
@@ -97,52 +99,52 @@ Iterable<num> input = const [];
|
||||
var output;
|
||||
|
||||
List<Benchmark> makeBenchmarks(int length) => [
|
||||
Benchmark('toList', length, () {
|
||||
output = input.toList();
|
||||
}),
|
||||
Benchmark('toList.fixed', length, () {
|
||||
output = input.toList(growable: false);
|
||||
}),
|
||||
Benchmark('List.of', length, () {
|
||||
output = List<num>.of(input);
|
||||
}),
|
||||
Benchmark('List.of.fixed', length, () {
|
||||
output = List<num>.of(input, growable: false);
|
||||
}),
|
||||
Benchmark('List.num.from', length, () {
|
||||
output = List<num>.from(input);
|
||||
}),
|
||||
Benchmark('List.int.from', length, () {
|
||||
output = List<int>.from(input);
|
||||
}),
|
||||
Benchmark('List.num.from.fixed', length, () {
|
||||
output = List<num>.from(input, growable: false);
|
||||
}),
|
||||
Benchmark('List.int.from.fixed', length, () {
|
||||
output = List<int>.from(input, growable: false);
|
||||
}),
|
||||
Benchmark('List.num.unmodifiable', length, () {
|
||||
output = List<num>.unmodifiable(input);
|
||||
}),
|
||||
Benchmark('List.int.unmodifiable', length, () {
|
||||
output = List<int>.unmodifiable(input);
|
||||
}),
|
||||
Benchmark('spread.num', length, () {
|
||||
output = <num>[...input];
|
||||
}),
|
||||
Benchmark('spread.int', length, () {
|
||||
output = <int>[...input as dynamic];
|
||||
}),
|
||||
Benchmark('spread.int.cast', length, () {
|
||||
output = <int>[...input.cast<int>()];
|
||||
}),
|
||||
Benchmark('spread.int.map', length, () {
|
||||
output = <int>[...input.map((x) => x as int)];
|
||||
}),
|
||||
Benchmark('for.int', length, () {
|
||||
output = <int>[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<num>.of(input);
|
||||
}),
|
||||
Benchmark('List.of.fixed', length, () {
|
||||
output = List<num>.of(input, growable: false);
|
||||
}),
|
||||
Benchmark('List.num.from', length, () {
|
||||
output = List<num>.from(input);
|
||||
}),
|
||||
Benchmark('List.int.from', length, () {
|
||||
output = List<int>.from(input);
|
||||
}),
|
||||
Benchmark('List.num.from.fixed', length, () {
|
||||
output = List<num>.from(input, growable: false);
|
||||
}),
|
||||
Benchmark('List.int.from.fixed', length, () {
|
||||
output = List<int>.from(input, growable: false);
|
||||
}),
|
||||
Benchmark('List.num.unmodifiable', length, () {
|
||||
output = List<num>.unmodifiable(input);
|
||||
}),
|
||||
Benchmark('List.int.unmodifiable', length, () {
|
||||
output = List<int>.unmodifiable(input);
|
||||
}),
|
||||
Benchmark('spread.num', length, () {
|
||||
output = <num>[...input];
|
||||
}),
|
||||
Benchmark('spread.int', length, () {
|
||||
output = <int>[...input as dynamic];
|
||||
}),
|
||||
Benchmark('spread.int.cast', length, () {
|
||||
output = <int>[...input.cast<int>()];
|
||||
}),
|
||||
Benchmark('spread.int.map', length, () {
|
||||
output = <int>[...input.map((x) => x as int)];
|
||||
}),
|
||||
Benchmark('for.int', length, () {
|
||||
output = <int>[for (var n in input) n as int];
|
||||
}),
|
||||
];
|
||||
|
||||
void main() {
|
||||
final benchmarks = [...makeBenchmarks(2), ...makeBenchmarks(100)];
|
||||
|
||||
@@ -33,7 +33,7 @@ class Benchmark extends BenchmarkBase {
|
||||
final List<Iterable<num>> 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<int>(0, (sum, iterable) => sum + iterable.length);
|
||||
totalLength += variants.fold<int>(
|
||||
0,
|
||||
(sum, iterable) => sum + iterable.length,
|
||||
);
|
||||
}
|
||||
|
||||
// Sanity checks.
|
||||
@@ -99,52 +101,52 @@ Iterable<num> input = const [];
|
||||
var output;
|
||||
|
||||
List<Benchmark> makeBenchmarks(int length) => [
|
||||
Benchmark('toList', length, () {
|
||||
output = input.toList();
|
||||
}),
|
||||
Benchmark('toList.fixed', length, () {
|
||||
output = input.toList(growable: false);
|
||||
}),
|
||||
Benchmark('List.of', length, () {
|
||||
output = List<num>.of(input);
|
||||
}),
|
||||
Benchmark('List.of.fixed', length, () {
|
||||
output = List<num>.of(input, growable: false);
|
||||
}),
|
||||
Benchmark('List.num.from', length, () {
|
||||
output = List<num>.from(input);
|
||||
}),
|
||||
Benchmark('List.int.from', length, () {
|
||||
output = List<int>.from(input);
|
||||
}),
|
||||
Benchmark('List.num.from.fixed', length, () {
|
||||
output = List<num>.from(input, growable: false);
|
||||
}),
|
||||
Benchmark('List.int.from.fixed', length, () {
|
||||
output = List<int>.from(input, growable: false);
|
||||
}),
|
||||
Benchmark('List.num.unmodifiable', length, () {
|
||||
output = List<num>.unmodifiable(input);
|
||||
}),
|
||||
Benchmark('List.int.unmodifiable', length, () {
|
||||
output = List<int>.unmodifiable(input);
|
||||
}),
|
||||
Benchmark('spread.num', length, () {
|
||||
output = <num>[...input];
|
||||
}),
|
||||
Benchmark('spread.int', length, () {
|
||||
output = <int>[...input];
|
||||
}),
|
||||
Benchmark('spread.int.cast', length, () {
|
||||
output = <int>[...input.cast<int>()];
|
||||
}),
|
||||
Benchmark('spread.int.map', length, () {
|
||||
output = <int>[...input.map((x) => x as int)];
|
||||
}),
|
||||
Benchmark('for.int', length, () {
|
||||
output = <int>[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<num>.of(input);
|
||||
}),
|
||||
Benchmark('List.of.fixed', length, () {
|
||||
output = List<num>.of(input, growable: false);
|
||||
}),
|
||||
Benchmark('List.num.from', length, () {
|
||||
output = List<num>.from(input);
|
||||
}),
|
||||
Benchmark('List.int.from', length, () {
|
||||
output = List<int>.from(input);
|
||||
}),
|
||||
Benchmark('List.num.from.fixed', length, () {
|
||||
output = List<num>.from(input, growable: false);
|
||||
}),
|
||||
Benchmark('List.int.from.fixed', length, () {
|
||||
output = List<int>.from(input, growable: false);
|
||||
}),
|
||||
Benchmark('List.num.unmodifiable', length, () {
|
||||
output = List<num>.unmodifiable(input);
|
||||
}),
|
||||
Benchmark('List.int.unmodifiable', length, () {
|
||||
output = List<int>.unmodifiable(input);
|
||||
}),
|
||||
Benchmark('spread.num', length, () {
|
||||
output = <num>[...input];
|
||||
}),
|
||||
Benchmark('spread.int', length, () {
|
||||
output = <int>[...input];
|
||||
}),
|
||||
Benchmark('spread.int.cast', length, () {
|
||||
output = <int>[...input.cast<int>()];
|
||||
}),
|
||||
Benchmark('spread.int.map', length, () {
|
||||
output = <int>[...input.map((x) => x as int)];
|
||||
}),
|
||||
Benchmark('for.int', length, () {
|
||||
output = <int>[for (var n in input) n as int];
|
||||
}),
|
||||
];
|
||||
|
||||
void main() {
|
||||
final benchmarks = [...makeBenchmarks(2), ...makeBenchmarks(100)];
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -13,8 +13,8 @@ class MD5Bench extends BenchmarkBase {
|
||||
List<int> data;
|
||||
|
||||
MD5Bench()
|
||||
: data = List<int>.generate(size, (i) => i % 256, growable: false),
|
||||
super('MD5');
|
||||
: data = List<int>.generate(size, (i) => i % 256, growable: false),
|
||||
super('MD5');
|
||||
|
||||
@override
|
||||
void run() {
|
||||
|
||||
@@ -52,8 +52,10 @@ abstract class Benchmark<K> extends BenchmarkBase {
|
||||
final List<Map<Object?, Object>> 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<String> {
|
||||
|
||||
class MapOfBenchmark<K> extends Benchmark<K> {
|
||||
MapOfBenchmark(String sourceKind, int length)
|
||||
: super('Map', 'of', sourceKind, length);
|
||||
: super('Map', 'of', sourceKind, length);
|
||||
|
||||
@override
|
||||
void copy() {
|
||||
@@ -159,7 +161,7 @@ class MapOfBenchmark<K> extends Benchmark<K> {
|
||||
|
||||
class HashMapOfBenchmark<K> extends Benchmark<K> {
|
||||
HashMapOfBenchmark(String sourceKind, int length)
|
||||
: super('HashMap', 'of', sourceKind, length);
|
||||
: super('HashMap', 'of', sourceKind, length);
|
||||
|
||||
@override
|
||||
void copy() {
|
||||
@@ -169,7 +171,7 @@ class HashMapOfBenchmark<K> extends Benchmark<K> {
|
||||
|
||||
class MapCopyOfBenchmark<K> extends Benchmark<K> {
|
||||
MapCopyOfBenchmark(String sourceKind, int length)
|
||||
: super('Map', 'copyOf', sourceKind, length);
|
||||
: super('Map', 'copyOf', sourceKind, length);
|
||||
|
||||
@override
|
||||
void copy() {
|
||||
@@ -183,7 +185,7 @@ class MapCopyOfBenchmark<K> extends Benchmark<K> {
|
||||
|
||||
class HashMapCopyOfBenchmark<K> extends Benchmark<K> {
|
||||
HashMapCopyOfBenchmark(String sourceKind, int length)
|
||||
: super('HashMap', 'copyOf', sourceKind, length);
|
||||
: super('HashMap', 'copyOf', sourceKind, length);
|
||||
|
||||
@override
|
||||
void copy() {
|
||||
@@ -197,7 +199,7 @@ class HashMapCopyOfBenchmark<K> extends Benchmark<K> {
|
||||
|
||||
class MapFromEntriesBenchmark<K> extends Benchmark<K> {
|
||||
MapFromEntriesBenchmark(String sourceKind, int length)
|
||||
: super('Map', 'fromEntries', sourceKind, length);
|
||||
: super('Map', 'fromEntries', sourceKind, length);
|
||||
|
||||
@override
|
||||
void copy() {
|
||||
@@ -207,7 +209,7 @@ class MapFromEntriesBenchmark<K> extends Benchmark<K> {
|
||||
|
||||
class HashMapFromEntriesBenchmark<K> extends Benchmark<K> {
|
||||
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<String, Object> m2 = HashMap.of(m1);
|
||||
final Map<int, Object> m3 = Map.of({1: 66});
|
||||
final Map<int, Object> m4 = HashMap.of({1: 66});
|
||||
final Map<Object, Object> m5 = Map.identity()
|
||||
..[Thing()] = 1
|
||||
..[Thing()] = 2;
|
||||
final Map<Object, Object> m6 = HashMap.identity()
|
||||
..[Thing()] = 1
|
||||
..[Thing()] = 2;
|
||||
final Map<Object, Object> m5 =
|
||||
Map.identity()
|
||||
..[Thing()] = 1
|
||||
..[Thing()] = 2;
|
||||
final Map<Object, Object> m6 =
|
||||
HashMap.identity()
|
||||
..[Thing()] = 1
|
||||
..[Thing()] = 2;
|
||||
final Map<Object, Object> m7 = UnmodifiableMapView(m1);
|
||||
final Map<Object, Object> m8 = UnmodifiableMapView(m2);
|
||||
final Map<Object, Object> m9 = UnmodifiableMapView(m3);
|
||||
|
||||
@@ -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 = <String, String>{
|
||||
'0': '1',
|
||||
};
|
||||
const const1 = <String, String>{'0': '1'};
|
||||
|
||||
final final1 = <String, String>{
|
||||
'0': '1',
|
||||
};
|
||||
final final1 = <String, String>{'0': '1'};
|
||||
|
||||
const const5 = <String, String>{
|
||||
'0': '1',
|
||||
|
||||
@@ -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 = <String, String>{
|
||||
'0': '1',
|
||||
};
|
||||
const const1 = <String, String>{'0': '1'};
|
||||
|
||||
final final1 = <String, String>{
|
||||
'0': '1',
|
||||
};
|
||||
final final1 = <String, String>{'0': '1'};
|
||||
|
||||
const const5 = <String, String>{
|
||||
'0': '1',
|
||||
|
||||
@@ -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 = <String, String>{');
|
||||
for (int i = 0; i < mapSize; i++) {
|
||||
|
||||
@@ -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<int>(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<Uint8> 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<Double> 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<String> args) {
|
||||
List<int> lengthsInBytes = defaultLengthsInBytes;
|
||||
final emitter = Emitter(results);
|
||||
if (results['length'].isNotEmpty) {
|
||||
lengthsInBytes = (results['length'] as List<String>)
|
||||
.map(int.parse)
|
||||
.where((i) => i <= maxSizeInBytes)
|
||||
.toList();
|
||||
lengthsInBytes =
|
||||
(results['length'] as List<String>)
|
||||
.map(int.parse)
|
||||
.where((i) => i <= maxSizeInBytes)
|
||||
.toList();
|
||||
}
|
||||
final filter = results.rest.firstOrNull;
|
||||
final benchmarks = [
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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<Handle Function(), Object Function()>('GetRootLibraryUrl');
|
||||
|
||||
final setNativeResolverForTest = nativeFunctionsLib.lookupFunction<
|
||||
Void Function(Handle), void Function(Object)>('SetNativeResolverForTest');
|
||||
final setNativeResolverForTest = nativeFunctionsLib
|
||||
.lookupFunction<Void Function(Handle), void Function(Object)>(
|
||||
'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);
|
||||
}
|
||||
|
||||
@@ -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<Handle Function(), Object Function()>('GetRootLibraryUrl');
|
||||
|
||||
final setNativeResolverForTest = nativeFunctionsLib.lookupFunction<
|
||||
Void Function(Handle), void Function(Object)>('SetNativeResolverForTest');
|
||||
final setNativeResolverForTest = nativeFunctionsLib
|
||||
.lookupFunction<Void Function(Handle), void Function(Object)>(
|
||||
'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);
|
||||
}
|
||||
|
||||
@@ -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([]));
|
||||
|
||||
@@ -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([]));
|
||||
|
||||
@@ -44,38 +44,17 @@ final Map<String, Lib> 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<String, Lib> 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<String> originalArguments) async {
|
||||
|
||||
@@ -41,30 +41,12 @@ final Map<String, Lib> 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<String, Lib> 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<String> originalArguments) async {
|
||||
|
||||
@@ -28,7 +28,10 @@ class Pair {
|
||||
@pragma('wasm:never-inline')
|
||||
@pragma('dart2js:never-inline')
|
||||
List<Object> getPolymorphicListOfClass(
|
||||
int length, bool growable, bool withValues) {
|
||||
int length,
|
||||
bool growable,
|
||||
bool withValues,
|
||||
) {
|
||||
if (runtimeTrue) {
|
||||
if (withValues) {
|
||||
return List<Pair>.generate(length, (i) => Pair(i, i), growable: growable);
|
||||
@@ -44,11 +47,17 @@ List<Object> getPolymorphicListOfClass(
|
||||
@pragma('wasm:never-inline')
|
||||
@pragma('dart2js:never-inline')
|
||||
List<Object> 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<Object> list =
|
||||
getPolymorphicListOfRecords(0, runtimeTrue, false);
|
||||
final List<Object> 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<Object> list =
|
||||
getPolymorphicListOfRecords(N, !runtimeTrue, false);
|
||||
final List<Object> 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 = <Pair>[
|
||||
for (int i = 0; i < N; ++i) Pair(i, i),
|
||||
];
|
||||
final list = <Pair>[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<Pair>;
|
||||
|
||||
@@ -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 = <Pair>[
|
||||
for (int i = 0; i < N; ++i) Pair(i, i),
|
||||
];
|
||||
final list = <Pair>[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<Pair>;
|
||||
|
||||
@@ -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 = <Pair, int>{
|
||||
for (int i = 0; i < N; ++i) Pair(i, i): i,
|
||||
};
|
||||
final map = <Pair, int>{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 = <Pair>{
|
||||
for (int i = 0; i < N ~/ 2; ++i) Pair(i * 2, i * 2),
|
||||
};
|
||||
final set = <Pair>{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() {
|
||||
|
||||
@@ -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<TaskControlBlock?> blocks =
|
||||
List<TaskControlBlock?>.filled(Richards.NUMBER_OF_IDS, null);
|
||||
final List<TaskControlBlock?> blocks = List<TaskControlBlock?>.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;
|
||||
|
||||
@@ -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<TaskControlBlock> blocks =
|
||||
List<TaskControlBlock>.filled(Richards.NUMBER_OF_IDS, null);
|
||||
List<TaskControlBlock> blocks = List<TaskControlBlock>.filled(
|
||||
Richards.NUMBER_OF_IDS,
|
||||
null,
|
||||
);
|
||||
|
||||
/// Add an idle task to this scheduler.
|
||||
void addIdleTask(int id, int priority, Packet queue, int count) {
|
||||
|
||||
@@ -78,17 +78,17 @@ class WidgetCanUpdateBenchmark extends BenchmarkBase {
|
||||
|
||||
// All widgets have different types.
|
||||
static List<Widget> _widgets() => [
|
||||
AWidget(),
|
||||
BWidget(),
|
||||
CWidget(),
|
||||
DWidget(),
|
||||
EWidget(),
|
||||
FWidget(),
|
||||
WWidget<AWidget>(),
|
||||
WWidget<BWidget>(ref: const BWidget()),
|
||||
WWidget<CWidget>(ref: CWidget()),
|
||||
const WWidget<DWidget>(ref: DWidget()),
|
||||
];
|
||||
AWidget(),
|
||||
BWidget(),
|
||||
CWidget(),
|
||||
DWidget(),
|
||||
EWidget(),
|
||||
FWidget(),
|
||||
WWidget<AWidget>(),
|
||||
WWidget<BWidget>(ref: const BWidget()),
|
||||
WWidget<CWidget>(ref: CWidget()),
|
||||
const WWidget<DWidget>(ref: DWidget()),
|
||||
];
|
||||
// Bulk up list to reduce loop overheads.
|
||||
final List<Widget> widgets = _widgets() + _widgets() + _widgets();
|
||||
|
||||
@@ -116,17 +116,17 @@ class ValueKeyEqualBenchmark extends BenchmarkBase {
|
||||
|
||||
// All widgets the same class but distinguished on keys.
|
||||
static List<Widget> _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<Widget> 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());
|
||||
|
||||
@@ -80,17 +80,17 @@ class WidgetCanUpdateBenchmark extends BenchmarkBase {
|
||||
|
||||
// All widgets have different types.
|
||||
static List<Widget> _widgets() => [
|
||||
AWidget(),
|
||||
BWidget(),
|
||||
CWidget(),
|
||||
DWidget(),
|
||||
EWidget(),
|
||||
FWidget(),
|
||||
WWidget<AWidget>(),
|
||||
WWidget<BWidget>(ref: const BWidget()),
|
||||
WWidget<CWidget>(ref: CWidget()),
|
||||
const WWidget<DWidget>(ref: DWidget()),
|
||||
];
|
||||
AWidget(),
|
||||
BWidget(),
|
||||
CWidget(),
|
||||
DWidget(),
|
||||
EWidget(),
|
||||
FWidget(),
|
||||
WWidget<AWidget>(),
|
||||
WWidget<BWidget>(ref: const BWidget()),
|
||||
WWidget<CWidget>(ref: CWidget()),
|
||||
const WWidget<DWidget>(ref: DWidget()),
|
||||
];
|
||||
// Bulk up list to reduce loop overheads.
|
||||
final List<Widget> widgets = _widgets() + _widgets() + _widgets();
|
||||
|
||||
@@ -118,17 +118,17 @@ class ValueKeyEqualBenchmark extends BenchmarkBase {
|
||||
|
||||
// All widgets the same class but distinguished on keys.
|
||||
static List<Widget> _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<Widget> 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());
|
||||
|
||||
@@ -6,10 +6,7 @@
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
const executables = <String>[
|
||||
'dart',
|
||||
'dartaotruntime',
|
||||
];
|
||||
const executables = <String>['dart', 'dartaotruntime'];
|
||||
|
||||
const libs = <String>[
|
||||
'vm_platform_strong.dill',
|
||||
@@ -29,9 +26,7 @@ const snapshots = <String>[
|
||||
'kernel_worker',
|
||||
];
|
||||
|
||||
const resources = <String>[
|
||||
'devtools',
|
||||
];
|
||||
const resources = <String>['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) {
|
||||
|
||||
@@ -8,10 +8,7 @@
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
const executables = <String>[
|
||||
'dart',
|
||||
'dartaotruntime',
|
||||
];
|
||||
const executables = <String>['dart', 'dartaotruntime'];
|
||||
|
||||
const libs = <String>[
|
||||
'vm_platform_strong.dill',
|
||||
@@ -31,9 +28,7 @@ const snapshots = <String>[
|
||||
'kernel_worker',
|
||||
];
|
||||
|
||||
const resources = <String>[
|
||||
'devtools',
|
||||
];
|
||||
const resources = <String>['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) {
|
||||
|
||||
@@ -13,8 +13,8 @@ class SHA1Bench extends BenchmarkBase {
|
||||
List<int> data;
|
||||
|
||||
SHA1Bench()
|
||||
: data = List<int>.generate(size, (i) => i % 256, growable: false),
|
||||
super('SHA1');
|
||||
: data = List<int>.generate(size, (i) => i % 256, growable: false),
|
||||
super('SHA1');
|
||||
|
||||
@override
|
||||
void run() {
|
||||
|
||||
@@ -14,8 +14,8 @@ class SHA256Bench extends BenchmarkBase {
|
||||
List<int> data;
|
||||
|
||||
SHA256Bench()
|
||||
: data = List<int>.generate(size, (i) => i % 256, growable: false),
|
||||
super('SHA256');
|
||||
: data = List<int>.generate(size, (i) => i % 256, growable: false),
|
||||
super('SHA256');
|
||||
|
||||
@override
|
||||
void run() {
|
||||
|
||||
@@ -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<void> 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,
|
||||
|
||||
@@ -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<void> 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,
|
||||
|
||||
@@ -73,14 +73,19 @@ void busyWork() {
|
||||
exercise(UnmodifiableListView<int>(L3));
|
||||
exercise(L1.asMap().values);
|
||||
exercise(L1.toList().asMap().values);
|
||||
final M1 =
|
||||
Map<String, int>.fromIterables(<String>['a', 'b', 'c', 'd', 'e'], L1);
|
||||
final M1 = Map<String, int>.fromIterables(<String>[
|
||||
'a',
|
||||
'b',
|
||||
'c',
|
||||
'd',
|
||||
'e',
|
||||
], L1);
|
||||
final M2 = const <String, int>{
|
||||
'a': 104,
|
||||
'b': 101,
|
||||
'c': 108,
|
||||
'd': 108,
|
||||
'e': 111
|
||||
'e': 111,
|
||||
};
|
||||
exercise(M1.values);
|
||||
exercise(M2.values);
|
||||
|
||||
@@ -74,14 +74,19 @@ void busyWork() {
|
||||
exercise(UnmodifiableListView<int>(L3));
|
||||
exercise(L1.asMap().values);
|
||||
exercise(L1.toList().asMap().values);
|
||||
final M1 =
|
||||
Map<String, int>.fromIterables(<String>['a', 'b', 'c', 'd', 'e'], L1);
|
||||
final M1 = Map<String, int>.fromIterables(<String>[
|
||||
'a',
|
||||
'b',
|
||||
'c',
|
||||
'd',
|
||||
'e',
|
||||
], L1);
|
||||
final M2 = const <String, int>{
|
||||
'a': 104,
|
||||
'b': 101,
|
||||
'c': 108,
|
||||
'd': 108,
|
||||
'e': 111
|
||||
'e': 111,
|
||||
};
|
||||
exercise(M1.values);
|
||||
exercise(M2.values);
|
||||
|
||||
@@ -30,7 +30,7 @@ Future<void> main(List<String> 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<void> main(List<String> 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');
|
||||
|
||||
@@ -32,7 +32,7 @@ Future<void> main(List<String> 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<void> main(List<String> 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');
|
||||
|
||||
@@ -20,7 +20,7 @@ List<List<String> Function(String)> version1ax1500() {
|
||||
_f12,
|
||||
_f13,
|
||||
_f14,
|
||||
_f15
|
||||
_f15,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ List<List<String> Function(String)> version1bx1500() {
|
||||
_g12,
|
||||
_g13,
|
||||
_g14,
|
||||
_g15
|
||||
_g15,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ List<List<String> Function(String)> version2x1500() {
|
||||
_h12,
|
||||
_h13,
|
||||
_h14,
|
||||
_h15
|
||||
_h15,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ const List<int> assertionCounts = [
|
||||
250,
|
||||
500,
|
||||
750,
|
||||
1000
|
||||
1000,
|
||||
];
|
||||
|
||||
void generateBenchmarkClassesAndUtilities(IOSink output) {
|
||||
@@ -151,7 +151,10 @@ const instances = <dynamic>[
|
||||
|
||||
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();
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -53,18 +53,16 @@ void main() {
|
||||
}
|
||||
return iterations;
|
||||
}).report();
|
||||
SyncCallBenchmark('TypeLiteral.GenericFunction.ListOfNullableT.nullableInt',
|
||||
() {
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
getListOfNullableT<int?>();
|
||||
}
|
||||
return iterations;
|
||||
}).report();
|
||||
final foos = <Foo<Object?>>[
|
||||
Foo<int>(),
|
||||
Foo<int?>(),
|
||||
Foo<dynamic>(),
|
||||
];
|
||||
SyncCallBenchmark(
|
||||
'TypeLiteral.GenericFunction.ListOfNullableT.nullableInt',
|
||||
() {
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
getListOfNullableT<int?>();
|
||||
}
|
||||
return iterations;
|
||||
},
|
||||
).report();
|
||||
final foos = <Foo<Object?>>[Foo<int>(), Foo<int?>(), Foo<dynamic>()];
|
||||
final Foo fooInt = foos[int.parse('0')];
|
||||
final Foo fooNullableInt = foos[int.parse('1')];
|
||||
final Foo fooDynamic = foos[int.parse('2')];
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<int> data1;
|
||||
final List<int> 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<int> data1;
|
||||
final List<int> 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<int> data1;
|
||||
final List<int> 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<int> data1;
|
||||
final List<int> 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<int> data9;
|
||||
final List<int> 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<String> commandLineArguments) {
|
||||
Polymorphic4(length, 'view'),
|
||||
//
|
||||
Polymorphic5(length, 'array'),
|
||||
Polymorphic5(length, 'mixed')
|
||||
]
|
||||
Polymorphic5(length, 'mixed'),
|
||||
],
|
||||
];
|
||||
|
||||
// Warmup all benchmarks to ensure JIT compilers see full polymorphism.
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user