mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 14:39:38 +00:00
[benchmark] Import MD5/SHA1/SHA256/SkeletalAnimation/SkeletalAnimationSIMD benchmarks from benchmarks-internal
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>
This commit is contained in:
parent
675891ae0c
commit
9be24ce946
37
benchmarks/MD5/dart/md5.dart
Normal file
37
benchmarks/MD5/dart/md5.dart
Normal file
|
@ -0,0 +1,37 @@
|
|||
// 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();
|
||||
}
|
40
benchmarks/MD5/dart2/md5.dart
Normal file
40
benchmarks/MD5/dart2/md5.dart
Normal file
|
@ -0,0 +1,40 @@
|
|||
// 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() : super('MD5') {
|
||||
data = List<int>(size);
|
||||
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 = md5.convert(data);
|
||||
if (hex.encode(hash.bytes) != expected) {
|
||||
throw 'Incorrect HASH computed.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
MD5Bench().report();
|
||||
}
|
37
benchmarks/SHA1/dart/sha1.dart
Normal file
37
benchmarks/SHA1/dart/sha1.dart
Normal file
|
@ -0,0 +1,37 @@
|
|||
// 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 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();
|
||||
}
|
40
benchmarks/SHA1/dart2/sha1.dart
Normal file
40
benchmarks/SHA1/dart2/sha1.dart
Normal file
|
@ -0,0 +1,40 @@
|
|||
// 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() : super('SHA1') {
|
||||
data = List<int>(size);
|
||||
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();
|
||||
}
|
38
benchmarks/SHA256/dart/sha256.dart
Normal file
38
benchmarks/SHA256/dart/sha256.dart
Normal file
|
@ -0,0 +1,38 @@
|
|||
// 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 warmup() {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
run();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void run() {
|
||||
final hash = sha256.convert(data);
|
||||
if (hex.encode(hash.bytes) != expected) {
|
||||
throw 'Incorrect HASH computed.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
SHA256Bench().report();
|
||||
}
|
41
benchmarks/SHA256/dart2/sha256.dart
Normal file
41
benchmarks/SHA256/dart2/sha256.dart
Normal file
|
@ -0,0 +1,41 @@
|
|||
// 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() : super('SHA256') {
|
||||
data = List<int>(size);
|
||||
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 = sha256.convert(data);
|
||||
if (hex.encode(hash.bytes) != expected) {
|
||||
throw 'Incorrect HASH computed.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
SHA256Bench().report();
|
||||
}
|
33
benchmarks/SkeletalAnimation/dart/SkeletalAnimation.dart
Normal file
33
benchmarks/SkeletalAnimation/dart/SkeletalAnimation.dart
Normal file
|
@ -0,0 +1,33 @@
|
|||
// 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.
|
||||
|
||||
/// A Dart implementation of two computation kernels used for skeletal
|
||||
/// animation.
|
||||
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:benchmark_harness/benchmark_harness.dart';
|
||||
import 'package:vector_math/vector_math_operations.dart';
|
||||
|
||||
void main() {
|
||||
SkeletalAnimation().report();
|
||||
}
|
||||
|
||||
class SkeletalAnimation extends BenchmarkBase {
|
||||
SkeletalAnimation() : super('SkeletalAnimation');
|
||||
|
||||
final Float32List A = Float32List(16);
|
||||
final Float32List B = Float32List(16);
|
||||
final Float32List C = Float32List(16);
|
||||
final Float32List D = Float32List(4);
|
||||
final Float32List E = Float32List(4);
|
||||
|
||||
@override
|
||||
void run() {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
Matrix44Operations.multiply(C, 0, A, 0, B, 0);
|
||||
Matrix44Operations.transform4(E, 0, A, 0, D, 0);
|
||||
}
|
||||
}
|
||||
}
|
33
benchmarks/SkeletalAnimation/dart2/SkeletalAnimation.dart
Normal file
33
benchmarks/SkeletalAnimation/dart2/SkeletalAnimation.dart
Normal file
|
@ -0,0 +1,33 @@
|
|||
// 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.
|
||||
|
||||
/// A Dart implementation of two computation kernels used for skeletal
|
||||
/// animation.
|
||||
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:benchmark_harness/benchmark_harness.dart';
|
||||
import 'package:vector_math/vector_math_operations.dart';
|
||||
|
||||
void main() {
|
||||
SkeletalAnimation().report();
|
||||
}
|
||||
|
||||
class SkeletalAnimation extends BenchmarkBase {
|
||||
SkeletalAnimation() : super('SkeletalAnimation');
|
||||
|
||||
final Float32List A = Float32List(16);
|
||||
final Float32List B = Float32List(16);
|
||||
final Float32List C = Float32List(16);
|
||||
final Float32List D = Float32List(4);
|
||||
final Float32List E = Float32List(4);
|
||||
|
||||
@override
|
||||
void run() {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
Matrix44Operations.multiply(C, 0, A, 0, B, 0);
|
||||
Matrix44Operations.transform4(E, 0, A, 0, D, 0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
// 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.
|
||||
|
||||
/// A Dart implementation of two computation kernels used for skeletal
|
||||
/// animation. SIMD version.
|
||||
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:benchmark_harness/benchmark_harness.dart';
|
||||
import 'package:vector_math/vector_math_operations.dart';
|
||||
|
||||
void main() {
|
||||
SkeletalAnimationSIMD().report();
|
||||
}
|
||||
|
||||
class SkeletalAnimationSIMD extends BenchmarkBase {
|
||||
SkeletalAnimationSIMD() : super('SkeletalAnimationSIMD');
|
||||
|
||||
final Float32x4List A = Float32x4List(4);
|
||||
final Float32x4List B = Float32x4List(4);
|
||||
final Float32x4List C = Float32x4List(4);
|
||||
final Float32x4List D = Float32x4List(1);
|
||||
final Float32x4List E = Float32x4List(1);
|
||||
|
||||
@override
|
||||
void run() {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
Matrix44SIMDOperations.multiply(C, 0, A, 0, B, 0);
|
||||
Matrix44SIMDOperations.transform4(E, 0, A, 0, D, 0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
// 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.
|
||||
|
||||
/// A Dart implementation of two computation kernels used for skeletal
|
||||
/// animation. SIMD version.
|
||||
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:benchmark_harness/benchmark_harness.dart';
|
||||
import 'package:vector_math/vector_math_operations.dart';
|
||||
|
||||
void main() {
|
||||
SkeletalAnimationSIMD().report();
|
||||
}
|
||||
|
||||
class SkeletalAnimationSIMD extends BenchmarkBase {
|
||||
SkeletalAnimationSIMD() : super('SkeletalAnimationSIMD');
|
||||
|
||||
final Float32x4List A = Float32x4List(4);
|
||||
final Float32x4List B = Float32x4List(4);
|
||||
final Float32x4List C = Float32x4List(4);
|
||||
final Float32x4List D = Float32x4List(1);
|
||||
final Float32x4List E = Float32x4List(1);
|
||||
|
||||
@override
|
||||
void run() {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
Matrix44SIMDOperations.multiply(C, 0, A, 0, B, 0);
|
||||
Matrix44SIMDOperations.transform4(E, 0, A, 0, D, 0);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue