mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 01:45:06 +00:00
9be24ce946
Change-Id: I8b7a740091a438babfdd05dd81423b5593d3d7e3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156020 Commit-Queue: Martin Kustermann <kustermann@google.com> Reviewed-by: Jonas Termansen <sortie@google.com>
38 lines
887 B
Dart
38 lines
887 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 = '6556112372898c69e1de0bf689d8db26';
|
|
|
|
class MD5Bench extends BenchmarkBase {
|
|
List<int> data;
|
|
|
|
MD5Bench()
|
|
: 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);
|
|
if (hex.encode(hash.bytes) != expected) {
|
|
throw 'Incorrect HASH computed.';
|
|
}
|
|
}
|
|
}
|
|
|
|
void main() {
|
|
MD5Bench().report();
|
|
}
|