mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 15:21:54 +00:00
[ffi/benchmark] Fix FfiCall branchmarks.
- Fixes expect logic in Float.. and Double.. benchmarks. - Fixes expected values in the same benchmarks. - Fixes typos in a few FFI function lookups. - Adds expected value to 'Unexpected result' message. Change-Id: I16eff1cac451412b376f56c070c5b8127ff744e6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186284 Auto-Submit: Clement Skau <cskau@google.com> Commit-Queue: Clement Skau <cskau@google.com> Reviewed-by: Daco Harkes <dacoharkes@google.com>
This commit is contained in:
parent
98c83633a2
commit
9d03dd9378
|
@ -208,11 +208,11 @@ final function1Double = ffiTestFunctions
|
|||
|
||||
typedef NativeFunction2Double = Double Function(Double, Double);
|
||||
final function2Double = ffiTestFunctions
|
||||
.lookupFunction<NativeFunction2Double, Function2double>('Function1Double');
|
||||
.lookupFunction<NativeFunction2Double, Function2double>('Function2Double');
|
||||
|
||||
typedef NativeFunction4Double = Double Function(Double, Double, Double, Double);
|
||||
final function4Double = ffiTestFunctions
|
||||
.lookupFunction<NativeFunction4Double, Function4double>('Function1Double');
|
||||
.lookupFunction<NativeFunction4Double, Function4double>('Function4Double');
|
||||
|
||||
typedef NativeFunction10Double = Double Function(Double, Double, Double, Double,
|
||||
Double, Double, Double, Double, Double, Double);
|
||||
|
@ -941,9 +941,9 @@ class Floatx01 extends BenchmarkBase {
|
|||
@override
|
||||
void run() {
|
||||
final double x = doCall1Float(N);
|
||||
final double expected = N * (N - 1) / 2 + N * 42;
|
||||
if (0.999 * expected > x && x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x');
|
||||
final double expected = N * (17.0 + 42);
|
||||
if (0.999 * expected > x || x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x, expected $expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -954,9 +954,9 @@ class Floatx02 extends BenchmarkBase {
|
|||
@override
|
||||
void run() {
|
||||
final double x = doCall2Float(N);
|
||||
final double expected = N * 55.0;
|
||||
if (0.999 * expected > x && x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x');
|
||||
final double expected = N * (1.0 + 2.0);
|
||||
if (0.999 * expected > x || x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x, expected $expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -967,9 +967,9 @@ class Floatx04 extends BenchmarkBase {
|
|||
@override
|
||||
void run() {
|
||||
final double x = doCall4Float(N);
|
||||
final double expected = N * 55.0;
|
||||
if (0.999 * expected > x && x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x');
|
||||
final double expected = N * (1.0 + 2.0 + 3.0 + 4.0);
|
||||
if (0.999 * expected > x || x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x, expected $expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -980,9 +980,10 @@ class Floatx10 extends BenchmarkBase {
|
|||
@override
|
||||
void run() {
|
||||
final double x = doCall10Float(N);
|
||||
final double expected = N * 55.0;
|
||||
if (0.999 * expected > x && x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x');
|
||||
final double expected =
|
||||
N * (1.0 + 2.0 + 3.0 + 4.0 + 5.0 + 6.0 + 7.0 + 8.0 + 9.0 + 10.0);
|
||||
if (0.999 * expected > x || x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x, expected $expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -993,9 +994,29 @@ class Floatx20 extends BenchmarkBase {
|
|||
@override
|
||||
void run() {
|
||||
final double x = doCall20Float(N);
|
||||
final double expected = N * 220.0;
|
||||
if (0.999 * expected > x && x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x');
|
||||
final double expected = N *
|
||||
(1.0 +
|
||||
2.0 +
|
||||
3.0 +
|
||||
4.0 +
|
||||
5.0 +
|
||||
6.0 +
|
||||
7.0 +
|
||||
8.0 +
|
||||
9.0 +
|
||||
10.0 +
|
||||
11.0 +
|
||||
12.0 +
|
||||
13.0 +
|
||||
14.0 +
|
||||
15.0 +
|
||||
16.0 +
|
||||
17.0 +
|
||||
18.0 +
|
||||
19.0 +
|
||||
20.0);
|
||||
if (0.999 * expected > x || x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x, expected $expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1006,9 +1027,9 @@ class Doublex01 extends BenchmarkBase {
|
|||
@override
|
||||
void run() {
|
||||
final double x = doCall1Double(N);
|
||||
final double expected = N * (N - 1) / 2 + N * 42;
|
||||
if (0.999 * expected > x && x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x');
|
||||
final double expected = N * (17.0 + 42.0);
|
||||
if (0.999 * expected > x || x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x, expected $expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1019,9 +1040,9 @@ class Doublex02 extends BenchmarkBase {
|
|||
@override
|
||||
void run() {
|
||||
final double x = doCall2Double(N);
|
||||
final double expected = N * 55.0;
|
||||
if (0.999 * expected > x && x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x');
|
||||
final double expected = N * (1.0 + 2.0);
|
||||
if (0.999 * expected > x || x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x, expected $expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1032,9 +1053,9 @@ class Doublex04 extends BenchmarkBase {
|
|||
@override
|
||||
void run() {
|
||||
final double x = doCall4Double(N);
|
||||
final double expected = N * 55.0;
|
||||
if (0.999 * expected > x && x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x');
|
||||
final double expected = N * (1.0 + 2.0 + 3.0 + 4.0);
|
||||
if (0.999 * expected > x || x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x, expected $expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1045,9 +1066,10 @@ class Doublex10 extends BenchmarkBase {
|
|||
@override
|
||||
void run() {
|
||||
final double x = doCall10Double(N);
|
||||
final double expected = N * 55.0;
|
||||
if (0.999 * expected > x && x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x');
|
||||
final double expected =
|
||||
N * (1.0 + 2.0 + 3.0 + 4.0 + 5.0 + 6.0 + 7.0 + 8.0 + 9.0 + 10.0);
|
||||
if (0.999 * expected > x || x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x, expected $expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1058,9 +1080,29 @@ class Doublex20 extends BenchmarkBase {
|
|||
@override
|
||||
void run() {
|
||||
final double x = doCall20Double(N);
|
||||
final double expected = N * 220.0;
|
||||
if (0.999 * expected > x && x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x');
|
||||
final double expected = N *
|
||||
(1.0 +
|
||||
2.0 +
|
||||
3.0 +
|
||||
4.0 +
|
||||
5.0 +
|
||||
6.0 +
|
||||
7.0 +
|
||||
8.0 +
|
||||
9.0 +
|
||||
10.0 +
|
||||
11.0 +
|
||||
12.0 +
|
||||
13.0 +
|
||||
14.0 +
|
||||
15.0 +
|
||||
16.0 +
|
||||
17.0 +
|
||||
18.0 +
|
||||
19.0 +
|
||||
20.0);
|
||||
if (0.999 * expected > x || x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x, expected $expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,11 +210,11 @@ final function1Double = ffiTestFunctions
|
|||
|
||||
typedef NativeFunction2Double = Double Function(Double, Double);
|
||||
final function2Double = ffiTestFunctions
|
||||
.lookupFunction<NativeFunction2Double, Function2double>('Function1Double');
|
||||
.lookupFunction<NativeFunction2Double, Function2double>('Function2Double');
|
||||
|
||||
typedef NativeFunction4Double = Double Function(Double, Double, Double, Double);
|
||||
final function4Double = ffiTestFunctions
|
||||
.lookupFunction<NativeFunction4Double, Function4double>('Function1Double');
|
||||
.lookupFunction<NativeFunction4Double, Function4double>('Function4Double');
|
||||
|
||||
typedef NativeFunction10Double = Double Function(Double, Double, Double, Double,
|
||||
Double, Double, Double, Double, Double, Double);
|
||||
|
@ -943,9 +943,9 @@ class Floatx01 extends BenchmarkBase {
|
|||
@override
|
||||
void run() {
|
||||
final double x = doCall1Float(N);
|
||||
final double expected = N * (N - 1) / 2 + N * 42;
|
||||
if (0.999 * expected > x && x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x');
|
||||
final double expected = N * (17.0 + 42);
|
||||
if (0.999 * expected > x || x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x, expected $expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -956,9 +956,9 @@ class Floatx02 extends BenchmarkBase {
|
|||
@override
|
||||
void run() {
|
||||
final double x = doCall2Float(N);
|
||||
final double expected = N * 55.0;
|
||||
if (0.999 * expected > x && x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x');
|
||||
final double expected = N * (1.0 + 2.0);
|
||||
if (0.999 * expected > x || x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x, expected $expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -969,9 +969,9 @@ class Floatx04 extends BenchmarkBase {
|
|||
@override
|
||||
void run() {
|
||||
final double x = doCall4Float(N);
|
||||
final double expected = N * 55.0;
|
||||
if (0.999 * expected > x && x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x');
|
||||
final double expected = N * (1.0 + 2.0 + 3.0 + 4.0);
|
||||
if (0.999 * expected > x || x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x, expected $expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -982,9 +982,10 @@ class Floatx10 extends BenchmarkBase {
|
|||
@override
|
||||
void run() {
|
||||
final double x = doCall10Float(N);
|
||||
final double expected = N * 55.0;
|
||||
if (0.999 * expected > x && x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x');
|
||||
final double expected =
|
||||
N * (1.0 + 2.0 + 3.0 + 4.0 + 5.0 + 6.0 + 7.0 + 8.0 + 9.0 + 10.0);
|
||||
if (0.999 * expected > x || x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x, expected $expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -995,9 +996,29 @@ class Floatx20 extends BenchmarkBase {
|
|||
@override
|
||||
void run() {
|
||||
final double x = doCall20Float(N);
|
||||
final double expected = N * 220.0;
|
||||
if (0.999 * expected > x && x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x');
|
||||
final double expected = N *
|
||||
(1.0 +
|
||||
2.0 +
|
||||
3.0 +
|
||||
4.0 +
|
||||
5.0 +
|
||||
6.0 +
|
||||
7.0 +
|
||||
8.0 +
|
||||
9.0 +
|
||||
10.0 +
|
||||
11.0 +
|
||||
12.0 +
|
||||
13.0 +
|
||||
14.0 +
|
||||
15.0 +
|
||||
16.0 +
|
||||
17.0 +
|
||||
18.0 +
|
||||
19.0 +
|
||||
20.0);
|
||||
if (0.999 * expected > x || x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x, expected $expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1008,9 +1029,9 @@ class Doublex01 extends BenchmarkBase {
|
|||
@override
|
||||
void run() {
|
||||
final double x = doCall1Double(N);
|
||||
final double expected = N * (N - 1) / 2 + N * 42;
|
||||
if (0.999 * expected > x && x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x');
|
||||
final double expected = N * (17.0 + 42.0);
|
||||
if (0.999 * expected > x || x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x, expected $expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1021,9 +1042,9 @@ class Doublex02 extends BenchmarkBase {
|
|||
@override
|
||||
void run() {
|
||||
final double x = doCall2Double(N);
|
||||
final double expected = N * 55.0;
|
||||
if (0.999 * expected > x && x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x');
|
||||
final double expected = N * (1.0 + 2.0);
|
||||
if (0.999 * expected > x || x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x, expected $expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1034,9 +1055,9 @@ class Doublex04 extends BenchmarkBase {
|
|||
@override
|
||||
void run() {
|
||||
final double x = doCall4Double(N);
|
||||
final double expected = N * 55.0;
|
||||
if (0.999 * expected > x && x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x');
|
||||
final double expected = N * (1.0 + 2.0 + 3.0 + 4.0);
|
||||
if (0.999 * expected > x || x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x, expected $expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1047,9 +1068,10 @@ class Doublex10 extends BenchmarkBase {
|
|||
@override
|
||||
void run() {
|
||||
final double x = doCall10Double(N);
|
||||
final double expected = N * 55.0;
|
||||
if (0.999 * expected > x && x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x');
|
||||
final double expected =
|
||||
N * (1.0 + 2.0 + 3.0 + 4.0 + 5.0 + 6.0 + 7.0 + 8.0 + 9.0 + 10.0);
|
||||
if (0.999 * expected > x || x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x, expected $expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1060,9 +1082,29 @@ class Doublex20 extends BenchmarkBase {
|
|||
@override
|
||||
void run() {
|
||||
final double x = doCall20Double(N);
|
||||
final double expected = N * 220.0;
|
||||
if (0.999 * expected > x && x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x');
|
||||
final double expected = N *
|
||||
(1.0 +
|
||||
2.0 +
|
||||
3.0 +
|
||||
4.0 +
|
||||
5.0 +
|
||||
6.0 +
|
||||
7.0 +
|
||||
8.0 +
|
||||
9.0 +
|
||||
10.0 +
|
||||
11.0 +
|
||||
12.0 +
|
||||
13.0 +
|
||||
14.0 +
|
||||
15.0 +
|
||||
16.0 +
|
||||
17.0 +
|
||||
18.0 +
|
||||
19.0 +
|
||||
20.0);
|
||||
if (0.999 * expected > x || x > 1.001 * expected) {
|
||||
throw Exception('$name: Unexpected result: $x, expected $expected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue