num-bigint-dig/Cargo.toml
Josh Stone f44bd0aee2 Add a special case for single-digit divisors
It was pointed out in the blog post [Big Integers in Zig] that we don't
have a special case in `num-bigint` for single-digit divisors.  While
you can already get this optimization by dividing directly by `u32`,
it's easy to make small `BigUint` divisors work like this too.

    $ cargo benchcmp baseline single-div
     name                   baseline ns/iter  single-div ns/iter  diff ns/iter   diff %  speedup
     factorial_div_biguint  5,638,353         1,005,488             -4,632,865  -82.17%   x 5.61

`BigInt` will also gain from this, since it uses `BigUint` division
internally.

Running [zig-bn's facdiv-rs] shows a nice improvement too.  My i7-7700K
with Rust 1.26 goes from 4.15 seconds to just 0.65 -- a 6.38x speedup!

[Big Integers in Zig]: https://tiehuis.github.io/big-integers-in-zig#division-test-single-limb
[zig-bn's facdiv-rs]: https://github.com/tiehuis/zig-bn/tree/master/bench/facdiv/crate-facdiv-rs
2018-05-14 11:24:32 -07:00

55 lines
1.0 KiB
TOML

[package]
authors = ["The Rust Project Developers"]
description = "Big integer implementation for Rust"
documentation = "https://docs.rs/num-bigint"
homepage = "https://github.com/rust-num/num-bigint"
keywords = ["mathematics", "numerics", "bignum"]
categories = [ "algorithms", "data-structures", "science" ]
license = "MIT/Apache-2.0"
name = "num-bigint"
repository = "https://github.com/rust-num/num-bigint"
version = "0.1.43"
readme = "README.md"
[[bench]]
name = "bigint"
[[bench]]
name = "factorial"
[[bench]]
name = "gcd"
[[bench]]
harness = false
name = "shootout-pidigits"
[dependencies]
[dependencies.num-integer]
version = "0.1.36"
default-features = false
[dependencies.num-traits]
version = "0.2.0"
default-features = false
features = ["std"]
[dependencies.rand]
optional = true
version = ">= 0.3.14, < 0.5.0"
[dependencies.rustc-serialize]
optional = true
version = "0.3.19"
[dependencies.serde]
optional = true
version = ">= 0.7.0, < 0.9.0"
[dev-dependencies.rand]
version = ">= 0.3.14, < 0.5.0"
[features]
default = ["rand", "rustc-serialize"]