Files
Robert Nystrom e4c8b49dcc Format benchmarks/.
Change-Id: I1362ada67a02b0ed352612fc29c727e94d8cd254
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394901
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2024-11-18 10:06:01 +00:00

31 lines
808 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 = 'ecca46e1a1d0a6012713b09a870d84f695b6d9b0';
class SHA1Bench extends BenchmarkBase {
List<int> data;
SHA1Bench()
: data = List<int>.generate(size, (i) => i % 256, growable: false),
super('SHA1');
@override
void run() {
final hash = sha1.convert(data);
if (hex.encode(hash.bytes) != expected) {
throw 'Incorrect HASH computed.';
}
}
}
void main() {
SHA1Bench().report();
}