Reformat benchmarks/ with 3.8 style.
Change-Id: Ied900f7d85addabc586823139aa78b879be035ea Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425182 Auto-Submit: Bob Nystrom <rnystrom@google.com> Reviewed-by: Lasse Nielsen <lrn@google.com> Commit-Queue: Lasse Nielsen <lrn@google.com>
This commit is contained in:
committed by
Commit Queue
parent
237ba8de01
commit
ff87171f6c
@@ -335,8 +335,7 @@ void main() {
|
||||
|
||||
// Warm up all benchmarks to ensure consistent behavior of shared code.
|
||||
benchmarks.forEach(
|
||||
(bm) =>
|
||||
bm()
|
||||
(bm) => bm()
|
||||
..setup()
|
||||
..run()
|
||||
..run(),
|
||||
|
||||
@@ -83,8 +83,7 @@ class BenchmarkAlternatingSizedAdd extends AsyncBenchmarkBase {
|
||||
@override
|
||||
Future<void> setup() async {
|
||||
_tempDir = Directory.systemTemp.createTempSync();
|
||||
_ioSink =
|
||||
File(
|
||||
_ioSink = File(
|
||||
_tempDir.uri.resolve('alternative-add-size').toFilePath(),
|
||||
).openWrite();
|
||||
}
|
||||
|
||||
@@ -54,8 +54,8 @@ 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),
|
||||
|
||||
@@ -118,8 +118,9 @@ class BenchmarkConfig {
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
final jsonString =
|
||||
File('benchmarks/IsolateJson/dart/sample.json').readAsStringSync();
|
||||
final jsonString = File(
|
||||
'benchmarks/IsolateJson/dart/sample.json',
|
||||
).readAsStringSync();
|
||||
final json250KB = utf8.encode(jsonString); // 294356 bytes
|
||||
final decoded = json.decode(utf8.decode(json250KB));
|
||||
final decoded1MB = <dynamic, dynamic>{
|
||||
|
||||
@@ -15,8 +15,8 @@ class SpawnLatency {
|
||||
final completerResult = Completer();
|
||||
final receivePort = ReceivePort()..listen(completerResult.complete);
|
||||
final isolateExitedCompleter = Completer<DateTime>();
|
||||
final onExitReceivePort =
|
||||
ReceivePort()..listen((_) {
|
||||
final onExitReceivePort = ReceivePort()
|
||||
..listen((_) {
|
||||
isolateExitedCompleter.complete(DateTime.now());
|
||||
});
|
||||
final beforeSpawn = DateTime.now();
|
||||
@@ -32,8 +32,9 @@ class SpawnLatency {
|
||||
receivePort.close();
|
||||
final DateTime isolateExited = await isolateExitedCompleter.future;
|
||||
result.timeToExitUs = isolateExited.difference(beforeSpawn).inMicroseconds;
|
||||
result.timeToIsolateSpawnUs =
|
||||
afterSpawn.difference(beforeSpawn).inMicroseconds;
|
||||
result.timeToIsolateSpawnUs = afterSpawn
|
||||
.difference(beforeSpawn)
|
||||
.inMicroseconds;
|
||||
onExitReceivePort.close();
|
||||
|
||||
return result;
|
||||
@@ -139,7 +140,8 @@ class AggregatedResultMessageLatency {
|
||||
);
|
||||
|
||||
@override
|
||||
String toString() => '''$toAfterIsolateSpawnUs
|
||||
String toString() =>
|
||||
'''$toAfterIsolateSpawnUs
|
||||
$toStartRunningCodeUs
|
||||
$toFinishRunningCodeUs
|
||||
$toExitUs''';
|
||||
@@ -164,10 +166,12 @@ Future<void> isolateCompiler(StartMessageLatency start) async {
|
||||
final timeFinishRunningCodeUs = DateTime.now();
|
||||
start.sendPort.send(
|
||||
ResultMessageLatency(
|
||||
timeToStartRunningCodeUs:
|
||||
timeRunningCodeUs.difference(start.spawned).inMicroseconds,
|
||||
timeToFinishRunningCodeUs:
|
||||
timeFinishRunningCodeUs.difference(start.spawned).inMicroseconds,
|
||||
timeToStartRunningCodeUs: timeRunningCodeUs
|
||||
.difference(start.spawned)
|
||||
.inMicroseconds,
|
||||
timeToFinishRunningCodeUs: timeFinishRunningCodeUs
|
||||
.difference(start.spawned)
|
||||
.inMicroseconds,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -224,12 +224,10 @@ 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()
|
||||
final Map<Object, Object> m5 = Map.identity()
|
||||
..[Thing()] = 1
|
||||
..[Thing()] = 2;
|
||||
final Map<Object, Object> m6 =
|
||||
HashMap.identity()
|
||||
final Map<Object, Object> m6 = HashMap.identity()
|
||||
..[Thing()] = 1
|
||||
..[Thing()] = 2;
|
||||
final Map<Object, Object> m7 = UnmodifiableMapView(m1);
|
||||
|
||||
@@ -13,8 +13,7 @@ import 'package:ffi/ffi.dart';
|
||||
|
||||
const maxSizeInBytes = 10 * 1024 * 1024;
|
||||
|
||||
final argParser =
|
||||
ArgParser()
|
||||
final argParser = ArgParser()
|
||||
..addMultiOption(
|
||||
'length',
|
||||
abbr: 'l',
|
||||
@@ -118,8 +117,7 @@ abstract class MemoryCopyBenchmark {
|
||||
// to avoid discarding results that almost, but not quite, reach the minimum
|
||||
// duration requested.
|
||||
final allowedJitter = Duration(
|
||||
microseconds:
|
||||
minDuration.inSeconds > 0
|
||||
microseconds: minDuration.inSeconds > 0
|
||||
? (minDuration.inMicroseconds * 0.1).floor()
|
||||
: 0,
|
||||
);
|
||||
@@ -475,8 +473,7 @@ void main(List<String> args) {
|
||||
List<int> lengthsInBytes = defaultLengthsInBytes;
|
||||
final emitter = Emitter(results);
|
||||
if (results['length'].isNotEmpty) {
|
||||
lengthsInBytes =
|
||||
(results['length'] as List<String>)
|
||||
lengthsInBytes = (results['length'] as List<String>)
|
||||
.map(int.parse)
|
||||
.where((i) => i <= maxSizeInBytes)
|
||||
.toList();
|
||||
|
||||
@@ -69,18 +69,14 @@ 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')
|
||||
|
||||
@@ -50,8 +50,10 @@ final Map<String, Lib> benchmarks = {
|
||||
'ListCopy': Lib(lib_ListCopy.loadLibrary, () => lib_ListCopy.main()),
|
||||
'MapCopy': Lib(lib_MapCopy.loadLibrary, () => lib_MapCopy.main([])),
|
||||
'MD5': Lib(lib_MD5.loadLibrary, () => lib_MD5.main()),
|
||||
'MultipleReturns':
|
||||
Lib(lib_MultipleReturns.loadLibrary, () => lib_MultipleReturns.main()),
|
||||
'MultipleReturns': Lib(
|
||||
lib_MultipleReturns.loadLibrary,
|
||||
() => lib_MultipleReturns.main(),
|
||||
),
|
||||
'RecordCollections': Lib(
|
||||
lib_RecordCollections.loadLibrary,
|
||||
() => lib_RecordCollections.main(),
|
||||
|
||||
@@ -23,8 +23,9 @@ Future<void> main(List<String> args) async {
|
||||
var events;
|
||||
try {
|
||||
tempDir = await Directory.systemTemp.createTemp();
|
||||
final timelinePath =
|
||||
tempDir.uri.resolve('Startup-timeline.json').toFilePath();
|
||||
final timelinePath = tempDir.uri
|
||||
.resolve('Startup-timeline.json')
|
||||
.toFilePath();
|
||||
final p = await Process.run(Platform.executable, [
|
||||
...Platform.executableArguments,
|
||||
'--timeline_recorder=file:$timelinePath',
|
||||
|
||||
@@ -137,8 +137,12 @@ class InstantiateSimple2DUiMatrix extends BenchmarkBase {
|
||||
void run() {
|
||||
double total = 0;
|
||||
for (int i = 0; i < N; i++) {
|
||||
total +=
|
||||
UiMatrix.simple2d(scaleX: 1.2, scaleY: 2.3, dx: 0.4, dy: 3.45).scaleX;
|
||||
total += UiMatrix.simple2d(
|
||||
scaleX: 1.2,
|
||||
scaleY: 2.3,
|
||||
dx: 0.4,
|
||||
dy: 3.45,
|
||||
).scaleX;
|
||||
}
|
||||
sink = total;
|
||||
}
|
||||
@@ -170,8 +174,7 @@ 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(
|
||||
total += UiMatrix.transform2d(
|
||||
scaleX: cosAngle,
|
||||
scaleY: cosAngle,
|
||||
k1: -sinAngle,
|
||||
@@ -226,8 +229,7 @@ class MultiplyIdentityByIdentityUiMatrix extends BenchmarkBase {
|
||||
class MultiplySimply2DByIdentityMatrix4 extends BenchmarkBase {
|
||||
MultiplySimply2DByIdentityMatrix4()
|
||||
: super('UiMatrix.Multiply_Simple2DByIdentity_Matrix4') {
|
||||
a4 =
|
||||
Matrix4.identity()
|
||||
a4 = Matrix4.identity()
|
||||
..translate(0.4, 3.45)
|
||||
..scale(1.2, 2.3);
|
||||
b4 = Matrix4.identity();
|
||||
@@ -263,12 +265,10 @@ class MultiplySimply2DByIdentityUiMatrix extends BenchmarkBase {
|
||||
class MultiplySimple2DBySimple2DMatrix4 extends BenchmarkBase {
|
||||
MultiplySimple2DBySimple2DMatrix4()
|
||||
: super('UiMatrix.Multiply_Simple2DBySimple2D_Matrix4') {
|
||||
a4 =
|
||||
Matrix4.identity()
|
||||
a4 = Matrix4.identity()
|
||||
..translate(0.4, 3.45)
|
||||
..scale(1.2, 2.3);
|
||||
b4 =
|
||||
Matrix4.identity()
|
||||
b4 = Matrix4.identity()
|
||||
..translate(0.5, 3.46)
|
||||
..scale(1.7, 2.8);
|
||||
}
|
||||
@@ -301,12 +301,10 @@ class MultiplySimple2DBySimple2DUiMatrix extends BenchmarkBase {
|
||||
class MultiplyComplexByComplexMatrix4 extends BenchmarkBase {
|
||||
MultiplyComplexByComplexMatrix4()
|
||||
: super('UiMatrix.Multiply_ComplexByComplex_Matrix4') {
|
||||
a4 =
|
||||
Matrix4.identity()
|
||||
a4 = Matrix4.identity()
|
||||
..rotateZ(0.1)
|
||||
..translate(0.4, 3.45);
|
||||
b4 =
|
||||
Matrix4.identity()
|
||||
b4 = Matrix4.identity()
|
||||
..rotateZ(0.2)
|
||||
..translate(0.3, 3.44);
|
||||
}
|
||||
@@ -385,8 +383,7 @@ class AddIdentityPlusIdentityUiMatrix extends BenchmarkBase {
|
||||
class AddSimple2DPlusIdentityMatrix4 extends BenchmarkBase {
|
||||
AddSimple2DPlusIdentityMatrix4()
|
||||
: super('UiMatrix.Add_Simple2DPlusIdentity_Matrix4') {
|
||||
a4 =
|
||||
Matrix4.identity()
|
||||
a4 = Matrix4.identity()
|
||||
..translate(0.4, 3.45)
|
||||
..scale(1.2, 2.3);
|
||||
b4 = Matrix4.identity();
|
||||
@@ -420,12 +417,10 @@ class AddSimple2DPlusIdentityUiMatrix extends BenchmarkBase {
|
||||
class AddSimple2DPlusSimple2DMatrix4 extends BenchmarkBase {
|
||||
AddSimple2DPlusSimple2DMatrix4()
|
||||
: super('UiMatrix.Add_Simple2DPlusSimple2D_Matrix4') {
|
||||
a4 =
|
||||
Matrix4.identity()
|
||||
a4 = Matrix4.identity()
|
||||
..translate(0.4, 3.45)
|
||||
..scale(1.2, 2.3);
|
||||
b4 =
|
||||
Matrix4.identity()
|
||||
b4 = Matrix4.identity()
|
||||
..translate(0.5, 3.46)
|
||||
..scale(1.7, 2.8);
|
||||
}
|
||||
@@ -458,12 +453,10 @@ class AddSimple2DPlusSimple2DUiMatrix extends BenchmarkBase {
|
||||
class AddComplexPlusComplexMatrix4 extends BenchmarkBase {
|
||||
AddComplexPlusComplexMatrix4()
|
||||
: super('UiMatrix.Add_ComplexPlusComplex_Matrix4') {
|
||||
a4 =
|
||||
Matrix4.identity()
|
||||
a4 = Matrix4.identity()
|
||||
..rotateZ(0.1)
|
||||
..translate(0.4, 3.45);
|
||||
b4 =
|
||||
Matrix4.identity()
|
||||
b4 = Matrix4.identity()
|
||||
..rotateZ(0.2)
|
||||
..translate(0.3, 3.44);
|
||||
}
|
||||
@@ -540,8 +533,7 @@ class InversionIdentityUiMatrix extends BenchmarkBase {
|
||||
|
||||
class InversionSimple2DMatrix4 extends BenchmarkBase {
|
||||
InversionSimple2DMatrix4() : super('UiMatrix.Inversion_Simple2D_Matrix4') {
|
||||
a4 =
|
||||
Matrix4.identity()
|
||||
a4 = Matrix4.identity()
|
||||
..translate(0.4, 3.45)
|
||||
..scale(1.2, 2.3);
|
||||
}
|
||||
@@ -574,8 +566,7 @@ class InversionSimple2DUiMatrix extends BenchmarkBase {
|
||||
|
||||
class InversionComplexMatrix4 extends BenchmarkBase {
|
||||
InversionComplexMatrix4() : super('UiMatrix.Inversion_Complex_Matrix4') {
|
||||
a4 =
|
||||
Matrix4.identity()
|
||||
a4 = Matrix4.identity()
|
||||
..rotateZ(0.1)
|
||||
..translate(0.4, 3.45);
|
||||
}
|
||||
@@ -646,8 +637,7 @@ class DeterminantIdentityUiMatrix extends BenchmarkBase {
|
||||
class DeterminantSimple2DMatrix4 extends BenchmarkBase {
|
||||
DeterminantSimple2DMatrix4()
|
||||
: super('UiMatrix.Determinant_Simple2D_Matrix4') {
|
||||
a4 =
|
||||
Matrix4.identity()
|
||||
a4 = Matrix4.identity()
|
||||
..translate(0.4, 3.45)
|
||||
..scale(1.2, 2.3);
|
||||
}
|
||||
@@ -678,8 +668,7 @@ class DeterminantSimple2DUiMatrix extends BenchmarkBase {
|
||||
|
||||
class DeterminantComplexMatrix4 extends BenchmarkBase {
|
||||
DeterminantComplexMatrix4() : super('UiMatrix.Determinant_Complex_Matrix4') {
|
||||
a4 =
|
||||
Matrix4.identity()
|
||||
a4 = Matrix4.identity()
|
||||
..rotateZ(0.1)
|
||||
..translate(0.4, 3.45);
|
||||
}
|
||||
|
||||
@@ -27,8 +27,7 @@ class Utf8Decode extends BenchmarkBase {
|
||||
|
||||
static String _makeName(String language, int size, bool allowMalformed) {
|
||||
String name = 'Utf8Decode.$language.';
|
||||
name +=
|
||||
size >= 1000000
|
||||
name += size >= 1000000
|
||||
? '${size ~/ 1000000}M'
|
||||
: size >= 1000
|
||||
? '${size ~/ 1000}k'
|
||||
|
||||
@@ -26,8 +26,7 @@ class Utf8Encode extends BenchmarkBase {
|
||||
|
||||
static String _makeName(String language, int size) {
|
||||
String name = 'Utf8Encode.$language.';
|
||||
name +=
|
||||
size >= 1000000
|
||||
name += size >= 1000000
|
||||
? '${size ~/ 1000000}M'
|
||||
: size >= 1000
|
||||
? '${size ~/ 1000}k'
|
||||
|
||||
Reference in New Issue
Block a user