Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: wasmx/fizzy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b28ad5ef906ca5c2df712efc915be07b2e82bfc1
Choose a base ref
..
head repository: wasmx/fizzy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 087b6d9c0363b250438401ecbb84a5d2ffd27e66
Choose a head ref
12 changes: 10 additions & 2 deletions test/bench/bench.cpp
Original file line number Diff line number Diff line change
@@ -79,6 +79,7 @@ struct ExecutionBenchmarkCase
{
std::shared_ptr<const fizzy::bytes> wasm_binary;
std::string func_name;
std::string func_sig;
std::vector<uint64_t> func_args;
fizzy::bytes memory;
std::optional<uint64_t> expected_result;
@@ -96,7 +97,7 @@ bool validate_benchmark_case(benchmark::State& state, fizzy::test::WasmEngine& e
return false;
}

const auto func_ref = engine.find_function(benchmark_case.func_name);
const auto func_ref = engine.find_function(benchmark_case.func_name, benchmark_case.func_sig);
if (!func_ref)
{
state.SkipWithError(("Function \"" + benchmark_case.func_name + "\" not found").c_str());
@@ -171,7 +172,7 @@ void benchmark_execute(
if (ok)
{
engine->instantiate(*benchmark_case.wasm_binary);
func_ref = engine->find_function(benchmark_case.func_name);
func_ref = engine->find_function(benchmark_case.func_name, benchmark_case.func_sig);
}

for ([[maybe_unused]] auto _ : state)
@@ -226,6 +227,7 @@ void load_benchmark(const fs::path& path, const std::string& name_prefix)
{
Name,
FuncName,
FuncSignature,
FuncArguments,
Memory,
ExpectedResult,
@@ -254,6 +256,12 @@ void load_benchmark(const fs::path& path, const std::string& name_prefix)

case InputsReadingState::FuncName:
benchmark_case->func_name = std::move(l);
st = InputsReadingState::FuncSignature;
break;

case InputsReadingState::FuncSignature:
fizzy::test::validate_function_signature(l);
benchmark_case->func_sig = std::move(l);
st = InputsReadingState::FuncArguments;
break;

12 changes: 8 additions & 4 deletions test/benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -12,10 +12,12 @@ Execution case is specified by 6 lines:

1. The case name. Must not be empty.
2. The exported wasm function name to be executed.
3. The function arguments as space-separated list of integers. May be empty.
4. The hex-encoded bytes of the initial memory. May be empty.
5. The expected result as an integer. Empty line means no result is expected.
6. The hex-encoded bytes of the expected memory after execution.
3. The function type where the parameter type(s) and the result type is separated with a colon (`:`).
The only allowed types currently are `i` for i32 and `I` for i64. e.g. `i:` for i32 input and no result.
4. The function arguments as space-separated list of integers. May be empty.
5. The hex-encoded bytes of the initial memory. May be empty.
6. The expected result as an integer. Empty line means no result is expected.
7. The hex-encoded bytes of the expected memory after execution.
If empty, result memory will not be checked.

Additional empty lines are allowed before each case.
@@ -25,13 +27,15 @@ Additional empty lines are allowed before each case.
```
case_1
testFunction
iii:i
2 3 4
000000ff
1
ff000000ff000000
case_2
memset
iii:
0 0xfe 3
2 changes: 2 additions & 0 deletions test/benchmarks/blake2b.inputs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
512_bytes_rounds_1
blake2b_bench
iii:i
512 85 1

885469211

512_bytes_rounds_16
blake2b_bench
iii:i
512 85 16

144115026
1 change: 1 addition & 0 deletions test/benchmarks/ecpairing.inputs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
onepoint
ecpairing_onepoint
:



2 changes: 2 additions & 0 deletions test/benchmarks/keccak256.inputs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
512_bytes_rounds_1
keccak256_bench
iii:i
512 85 1

3375723258

512_bytes_rounds_16
keccak256_bench
iii:i
512 85 16

2231363705
2 changes: 2 additions & 0 deletions test/benchmarks/memset.inputs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
256_bytes
memset_bench
ii:i
85 256

21760

60000_bytes
memset_bench
ii:i
85 60000

5100000
2 changes: 2 additions & 0 deletions test/benchmarks/micro/factorial.inputs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
10
factorial
I:I
10

3628800

20
factorial
I:I
20

2432902008176640000
1 change: 1 addition & 0 deletions test/benchmarks/micro/fibonacci.inputs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
24
fibonacci
i:i
24

46368
3 changes: 3 additions & 0 deletions test/benchmarks/micro/host_adler32.inputs
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
1
host_adler32
i:i
1

22544555

100
host_adler32
i:i
100

2254455500

1000
host_adler32
i:i
1000

1069718520
2 changes: 2 additions & 0 deletions test/benchmarks/micro/spinner.inputs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
1
spinner
i:
1



1000
spinner
i:
1000


2 changes: 2 additions & 0 deletions test/benchmarks/mul256_opt0.inputs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
input0
mul256
iii:
0 0 0




input1
mul256
iii:
64 0 32
0100000000000000000000000000000000000000000000000000000000000080 ff000000000000000000000000000000000000000000000000000000000000c0

2 changes: 2 additions & 0 deletions test/benchmarks/sha1.inputs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
512_bytes_rounds_1
sha1_bench
iii:i
512 85 1

2039494368

512_bytes_rounds_16
sha1_bench
iii:i
512 85 16

2669532376
2 changes: 2 additions & 0 deletions test/benchmarks/sha256.inputs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
512_bytes_rounds_1
sha256_bench
iii:i
512 85 1

4181377396

512_bytes_rounds_16
sha256_bench
iii:i
512 85 16

550469400
7 changes: 7 additions & 0 deletions test/smoketests/benchmarks/arith.inputs
Original file line number Diff line number Diff line change
@@ -1,42 +1,49 @@
addition
add
ii:i
1 2

3

division_by_zero
div
ii:i
1 0

0

memory_initialization_failure
add
ii:i
0 0
fe
0

unexcepted_result
div
ii:i
1 1



expected_memory_shorter
add
ii:i
0 0

0
00

missing_function
sub
ii:i
0 0

0

incorrect_result_value
add
ii:i
2 2

5
1 change: 1 addition & 0 deletions test/smoketests/benchmarks/invalid.inputs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
add
add
ii:i
1 2


1 change: 1 addition & 0 deletions test/smoketests/benchmarks/malformed/malformed.inputs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
fake
fake_func
:



3 changes: 3 additions & 0 deletions test/smoketests/benchmarks/memory.inputs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
increase_value
inc
i:
0
ff000000

@@ -8,13 +9,15 @@ ff000000

wrong_expected_memory
inc
i:
0
ff000000

ffffffff

missing_result_value
inc
i:
0

0
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
main
main
i:i
0

0
Loading