ExWeb3 / ex_keccak

Elixir library for computing Keccak SHA3-256 hashes using a NIF built tiny-keccak Rust crate.
Apache License 2.0
25 stars 20 forks source link

update rustler to 0.24 #25

Closed ayrat555 closed 2 years ago

ayrat555 commented 2 years ago

use NewBinary instead of OwnedBinary (https://github.com/rusterlium/rustler/blob/master/CHANGELOG.md#0240---2021-02-24)

I did some benchmarks

with NewBinary

Operating System: macOS
CPU Information: Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
Number of Available Cores: 8
Available memory: 16 GB
Elixir 1.12.1
Erlang 24.0.1

Benchmark suite executing with the following configuration:
warmup: 2 s
time: 1.67 min
memory time: 1.67 min
parallel: 4
inputs: none specified
Estimated total run time: 3.37 min

Benchmarking ex_keccak...

Name                ips        average  deviation         median         99th %
ex_keccak       61.15 K       16.35 μs   ±568.01%          11 μs          44 μs

Memory usage statistics:

Name         Memory usage
ex_keccak            48 B

with OwnedBinary

Operating System: macOS
CPU Information: Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
Number of Available Cores: 8
Available memory: 16 GB
Elixir 1.12.1
Erlang 24.0.1

Benchmark suite executing with the following configuration:
warmup: 2 s
time: 1.67 min
memory time: 1.67 min
parallel: 4
inputs: none specified
Estimated total run time: 3.37 min

Benchmarking ex_keccak...

Name                ips        average  deviation         median         99th %
ex_keccak       51.55 K       19.40 μs   ±650.83%          20 μs          54 μs

Memory usage statistics:

Name         Memory usage
ex_keccak            96 B

it seems with NewBinary the library performs better both in terms of memory and ips

tzumby commented 2 years ago

Awesome, thanks @ayrat555!