mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 08:20:31 +00:00
ea5840c2c5
The legacy Dart 2.9 benchmarks that used the default List(int size) constructor are changed to use the equivalent List.filled(size, null) constructor, because the default List constructor is removed. Bug: b/280275041 Change-Id: I2813537ae22e19d473abde70d677368940585423 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304700 Reviewed-by: Jonas Termansen <sortie@google.com> Commit-Queue: William Hesse <whesse@google.com>
42 lines
955 B
Dart
42 lines
955 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.
|
|
|
|
// @dart=2.9
|
|
|
|
import 'package:benchmark_harness/benchmark_harness.dart';
|
|
import 'package:convert/convert.dart';
|
|
import 'package:crypto/crypto.dart';
|
|
|
|
const size = 8 * 1024;
|
|
const expected = 'ecca46e1a1d0a6012713b09a870d84f695b6d9b0';
|
|
|
|
class SHA1Bench extends BenchmarkBase {
|
|
List<int> data;
|
|
|
|
SHA1Bench() : super('SHA1') {
|
|
data = List<int>.filled(size, null);
|
|
for (int i = 0; i < data.length; i++) {
|
|
data[i] = i % 256;
|
|
}
|
|
}
|
|
|
|
@override
|
|
void warmup() {
|
|
for (int i = 0; i < 4; i++) {
|
|
run();
|
|
}
|
|
}
|
|
|
|
@override
|
|
void run() {
|
|
final hash = sha1.convert(data);
|
|
if (hex.encode(hash.bytes) != expected) {
|
|
throw 'Incorrect HASH computed.';
|
|
}
|
|
}
|
|
}
|
|
|
|
void main() {
|
|
SHA1Bench().report();
|
|
}
|