danielhstahl / black_scholes_rust

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

Replace 1/sqrt(2*pi) calculations with constants #28

Closed sunsided closed 3 months ago

sunsided commented 3 months ago

This changes some function calls to avoid divisions and replace them with constants.


This PR also includes #27 for use of black_box in benchmarks. Compared to that I get slighly reduced mean durations with improved error bounds:

running 3 tests
test bench_all_price          ... bench:          57.02 ns/iter (+/- 3.87)
test bench_all_price_no_cache ... bench:         235.70 ns/iter (+/- 64.07)
test bench_call_price         ... bench:          38.98 ns/iter (+/- 6.24)

Like in #27, the benchmark test will also fail here due to the changed duration baselines.

coveralls commented 3 months ago

Pull Request Test Coverage Report for Build 9243534858

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details


Files with Coverage Reduction New Missed Lines %
src/lib.rs 1 79.97%
<!-- Total: 1 -->
Totals Coverage Status
Change from base Build 4354937295: -0.6%
Covered Lines: 407
Relevant Lines: 446

💛 - Coveralls
danielhstahl commented 3 months ago

Thank you, can you bump https://github.com/danielhstahl/black_scholes_rust/blob/master/Cargo.toml#L3 to 10.2?

sunsided commented 3 months ago

Done!