danielhstahl / black_scholes_rust

Rust for black scholes
https://danielhstahl.github.io/black_scholes_rust/dev/bench/
22 stars 8 forks source link

Add `black_box` to benchmarks #27

Closed sunsided closed 3 months ago

sunsided commented 3 months ago

This ensures the benchmarks do not accidentally optimize for the provided constants.

On my machine, this would change the reported benchmark results from

running 3 tests
test bench_all_price          ... bench:           2.44 ns/iter (+/- 0.79)
test bench_all_price_no_cache ... bench:          73.79 ns/iter (+/- 11.15)
test bench_call_price         ... bench:          43.34 ns/iter (+/- 14.57)

to

running 3 tests
test bench_all_price          ... bench:          61.22 ns/iter (+/- 30.21)
test bench_all_price_no_cache ... bench:         250.83 ns/iter (+/- 84.97)
test bench_call_price         ... bench:          40.98 ns/iter (+/- 21.33)

This should give a more accurate picture.

coveralls commented 3 months ago

Pull Request Test Coverage Report for Build 9243228171

Details


Files with Coverage Reduction New Missed Lines %
src/lib.rs 1 80.16%
<!-- Total: 1 -->
Totals Coverage Status
Change from base Build 4354937295: -0.4%
Covered Lines: 406
Relevant Lines: 445

💛 - Coveralls
sunsided commented 3 months ago

The benchmark test now obviously fails because the report baseline has changed.

danielhstahl commented 3 months ago

Didn't this get merged already? I'm surprised its not showing a merge conflict...

sunsided commented 3 months ago

@danielhstahl Must have been a glitch. I rebased it against master and now it's correctly an empty PR due to #28.

danielhstahl commented 3 months ago

Thanks @sunsided . Your changes have been deployed in 10.2: https://crates.io/crates/black_scholes