mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 15:42:20 +00:00
b6aa2976dc
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>
32 lines
850 B
Dart
32 lines
850 B
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.
|
|
|
|
import 'package:benchmark_harness/benchmark_harness.dart';
|
|
import 'package:convert/convert.dart';
|
|
import 'package:crypto/crypto.dart';
|
|
|
|
const size = 8 * 1024;
|
|
const expected =
|
|
'dc404a613fedaeb54034514bc6505f56b933caa5250299ba7d094377a51caa46';
|
|
|
|
class SHA256Bench extends BenchmarkBase {
|
|
List<int> data;
|
|
|
|
SHA256Bench()
|
|
: data = List<int>.generate(size, (i) => i % 256, growable: false),
|
|
super('SHA256');
|
|
|
|
@override
|
|
void run() {
|
|
final hash = sha256.convert(data);
|
|
if (hex.encode(hash.bytes) != expected) {
|
|
throw 'Incorrect HASH computed.';
|
|
}
|
|
}
|
|
}
|
|
|
|
void main() {
|
|
SHA256Bench().report();
|
|
}
|