mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:39:49 +00:00
68a57c59d7
A benchmark that is a collection of other benchmarks. This benchmark has two purposes: - As a medium sized compilation benchmark - As a tool for running benchmarks as part of a larger program This benchmark is not intended to be run for the purpose of generating benchmark timing results on Golem. It should be extended over time to include most public benchmarks that are meaningful on all Dart platforms. Change-Id: I17f034cfd68d01ff5b4842b89b216fcea0d5bd3c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170060 Commit-Queue: Stephen Adams <sra@google.com> Reviewed-by: William Hesse <whesse@google.com>
78 lines
2.5 KiB
Dart
78 lines
2.5 KiB
Dart
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
|
|
// 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.
|
|
//
|
|
// @dart=2.10
|
|
//
|
|
// A benchmark that contains several other benchmarks.
|
|
//
|
|
// With no arguments, run all benchmarks once.
|
|
// With arguments, run only the specified benchmarks in command-line order.
|
|
//
|
|
// -N: run benchmarks N times, defaults to once.
|
|
|
|
import '../../ListCopy/dart/ListCopy.dart' as lib_ListCopy;
|
|
import '../../BigIntParsePrint/dart/BigIntParsePrint.dart'
|
|
as lib_BigIntParsePrint;
|
|
import '../../MD5/dart/md5.dart' as lib_MD5;
|
|
import '../../RuntimeType/dart/RuntimeType.dart' as lib_RuntimeType;
|
|
import '../../SHA1/dart/sha1.dart' as lib_SHA1;
|
|
import '../../SHA256/dart/sha256.dart' as lib_SHA256;
|
|
import '../../SkeletalAnimation/dart/SkeletalAnimation.dart'
|
|
as lib_SkeletalAnimation;
|
|
import '../../SkeletalAnimationSIMD/dart/SkeletalAnimationSIMD.dart'
|
|
as lib_SkeletalAnimationSIMD;
|
|
import '../../TypedDataDuplicate/dart/TypedDataDuplicate.dart'
|
|
as lib_TypedDataDuplicate;
|
|
import '../../Utf8Decode/dart/Utf8Decode.dart' as lib_Utf8Decode;
|
|
import '../../Utf8Encode/dart/Utf8Encode.dart' as lib_Utf8Encode;
|
|
|
|
final Map<String, Function()> benchmarks = {
|
|
'ListCopy': lib_ListCopy.main,
|
|
'BigIntParsePrint': lib_BigIntParsePrint.main,
|
|
'MD5': lib_MD5.main,
|
|
'RuntimeType': lib_RuntimeType.main,
|
|
'SHA1': lib_SHA1.main,
|
|
'SHA256': lib_SHA256.main,
|
|
'SkeletalAnimation': lib_SkeletalAnimation.main,
|
|
'SkeletalAnimationSIMD': lib_SkeletalAnimationSIMD.main,
|
|
'TypedDataDuplicate': lib_TypedDataDuplicate.main,
|
|
'Utf8Decode': () => lib_Utf8Decode.main([]),
|
|
'Utf8Encode': () => lib_Utf8Encode.main([]),
|
|
};
|
|
|
|
main(List<String> originalArguments) {
|
|
List<String> args = List.of(originalArguments);
|
|
|
|
int repeats = 1;
|
|
|
|
for (final arg in args.toList()) {
|
|
int count = int.tryParse(arg);
|
|
if (count != null && count < 0) {
|
|
repeats = 0 - count;
|
|
args.remove(arg);
|
|
}
|
|
}
|
|
|
|
List<Function()> mains = [];
|
|
|
|
for (final name in args.toList()) {
|
|
final function = benchmarks[name];
|
|
if (function == null) {
|
|
print("Unknown benchmark: '$name'");
|
|
} else {
|
|
mains.add(function);
|
|
args.remove(name);
|
|
}
|
|
}
|
|
if (args.isNotEmpty) return; // We will have printed an error.
|
|
|
|
if (mains.isEmpty) mains = benchmarks.values.toList();
|
|
|
|
for (var i = 0; i < repeats; i++) {
|
|
for (final function in mains) {
|
|
function();
|
|
}
|
|
}
|
|
}
|