1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-01 07:14:29 +00:00

[benchmarks] Fix benchmarks warming up incorrectly.

The benchmarks were using a range of antipatterns that did not do what
the authors thought they did. It seems that the authors thought the
warmup method has to run for a while and do the full warmup, but the
truth is that the harness will do that for you by running the warmup
function in a timed loop. Instead these patterns just wasted time by
making the warmup more expensive and complex than needed.

This change just removes the warmup overrides since none of them do
anything positive. This change prepares us for future improvements to
the benchmark harness.

Fixes: b/324874055
Change-Id: Ib7c282123a2151614bc95a105a30e67221f11315
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352022
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Jonas Termansen <sortie@google.com>
This commit is contained in:
Jonas Termansen 2024-02-22 14:38:19 +00:00 committed by Commit Queue
parent e680eb4c4f
commit b6aa2976dc
16 changed files with 8 additions and 92 deletions

2
DEPS
View File

@ -57,7 +57,7 @@ vars = {
"co19_rev": "867d139b3169fc131488e893ec1133dc98cc3aa0",
# The internal benchmarks to use. See go/dart-benchmarks-internal
"benchmarks_internal_rev": "3e58fcfa1464ffd7b1d3edc7a8d5d9a24a321c5d",
"benchmarks_internal_rev": "175974d2b43dae39c380fc5f7f583a377cd3c11d",
"checkout_benchmarks_internal": False,
# Checkout the flute benchmark only when benchmarking.

View File

@ -508,7 +508,7 @@ void pollute() {
///
/// Run benchmarks with name containing all the dot-separated words in the
/// selector, so `--Set.const` will run benchmark
/// 'Iterators.const.Set.int.N`, and `--2.UpTo` will select
/// `Iterators.const.Set.int.N`, and `--2.UpTo` will select
/// `Iterators.UpTo.2`. Each selector is matched independently, and if
/// selectors are used, only benchmarks matching some selector are run.
///

View File

@ -26,13 +26,6 @@ class LongStringCompare extends BenchmarkBase {
s.add(single + '!' + single);
}
@override
void warmup() {
for (int i = 0; i < reps / 2; i++) {
run();
}
}
@override
void run() {
for (int i = 0; i < reps; i++) {

View File

@ -16,13 +16,6 @@ class MD5Bench extends BenchmarkBase {
: data = List<int>.generate(size, (i) => i % 256, growable: false),
super('MD5');
@override
void warmup() {
for (int i = 0; i < 4; i++) {
run();
}
}
@override
void run() {
final hash = md5.convert(data);

View File

@ -21,13 +21,6 @@ class MD5Bench extends BenchmarkBase {
}
}
@override
void warmup() {
for (int i = 0; i < 4; i++) {
run();
}
}
@override
void run() {
final hash = md5.convert(data);

View File

@ -16,13 +16,6 @@ class SHA1Bench extends BenchmarkBase {
: data = List<int>.generate(size, (i) => i % 256, growable: false),
super('SHA1');
@override
void warmup() {
for (int i = 0; i < 4; i++) {
run();
}
}
@override
void run() {
final hash = sha1.convert(data);

View File

@ -21,13 +21,6 @@ class SHA1Bench extends BenchmarkBase {
}
}
@override
void warmup() {
for (int i = 0; i < 4; i++) {
run();
}
}
@override
void run() {
final hash = sha1.convert(data);

View File

@ -17,13 +17,6 @@ class SHA256Bench extends BenchmarkBase {
: data = List<int>.generate(size, (i) => i % 256, growable: false),
super('SHA256');
@override
void warmup() {
for (int i = 0; i < 4; i++) {
run();
}
}
@override
void run() {
final hash = sha256.convert(data);

View File

@ -22,13 +22,6 @@ class SHA256Bench extends BenchmarkBase {
}
}
@override
void warmup() {
for (int i = 0; i < 4; i++) {
run();
}
}
@override
void run() {
final hash = sha256.convert(data);

View File

@ -24,13 +24,6 @@ abstract class Uint8ListCopyBenchmark extends BenchmarkBase {
}
}
@override
void warmup() {
for (var i = 0; i < 100; ++i) {
run();
}
}
@override
void teardown() {
for (var i = 0; i < size; ++i) {

View File

@ -26,13 +26,6 @@ abstract class Uint8ListCopyBenchmark extends BenchmarkBase {
}
}
@override
void warmup() {
for (var i = 0; i < 100; ++i) {
run();
}
}
@override
void teardown() {
for (var i = 0; i < size; ++i) {

View File

@ -29,7 +29,9 @@ class Utf8Decode extends BenchmarkBase {
String name = 'Utf8Decode.$language.';
name += size >= 1000000
? '${size ~/ 1000000}M'
: size >= 1000 ? '${size ~/ 1000}k' : '$size';
: size >= 1000
? '${size ~/ 1000}k'
: '$size';
if (allowMalformed) name += '.malformed';
return name;
}
@ -93,11 +95,6 @@ class Utf8Decode extends BenchmarkBase {
run();
}
@override
void warmup() {
BenchmarkBase.measureFor(run, 1000);
}
@override
double measure() {
// Report time per input byte.

View File

@ -31,7 +31,9 @@ class Utf8Decode extends BenchmarkBase {
String name = 'Utf8Decode.$language.';
name += size >= 1000000
? '${size ~/ 1000000}M'
: size >= 1000 ? '${size ~/ 1000}k' : '$size';
: size >= 1000
? '${size ~/ 1000}k'
: '$size';
if (allowMalformed) name += '.malformed';
return name;
}
@ -95,11 +97,6 @@ class Utf8Decode extends BenchmarkBase {
run();
}
@override
void warmup() {
BenchmarkBase.measureFor(run, 1000);
}
@override
double measure() {
// Report time per input byte.

View File

@ -164,11 +164,6 @@ class Utf8DecodeBenchmarkBase extends BenchmarkBase {
run();
}
@override
void warmup() {
BenchmarkBase.measureFor(run, 100);
}
@override
double measure() {
// Report time per input byte.

View File

@ -66,11 +66,6 @@ class Utf8Encode extends BenchmarkBase {
run();
}
@override
void warmup() {
BenchmarkBase.measureFor(run, 1000);
}
@override
double measure() {
// Report time per input rune.

View File

@ -69,11 +69,6 @@ class Utf8Encode extends BenchmarkBase {
run();
}
@override
void warmup() {
BenchmarkBase.measureFor(run, 1000);
}
@override
double measure() {
// Report time per input rune.