25个版本 (破坏性更新)
0.20.5 | 2022年3月22日 |
---|---|
0.19.0 | 2022年3月19日 |
0.10.0 | 2021年12月27日 |
#1335 in 数据结构
每月294次下载
用于 2 crates
69KB
1.5K SLoC
bitvec_simd
一个用于位向量的Rust库,特色包括:
使用方法
将bitvec_simd
添加到Cargo.toml
[dependencies]
bitvec_simd = "0.20"
如果您需要serde支持,可以这样包含功能
[dependencies]
bitvec_simd = { version = "0.20", features = ["serde"] }
如果您想在具有#![no_std]
的程序中使用bitvec_simd,只需删除默认功能
[dependencies]
bitvec_simd = { version = "0.20", default-features = false }
示例
let mut bitvec = BitVec::ones(1000); // create a bitvec contains 0 ..= 999
bitvec.set(900, false); // delete 900 from bitvec
bitvec.set(1200, true); // add 1200 to bitvec (and expand bitvec to length 1201)
let bitvec2 = BitVec::ones(1000);
let new_bitvec = bitvec.and_cloned(&bitvec2); // and operation, without consume
let new_bitvec2 = bitvec & bitvec2; // and operation, consume both bitvec
// Operation Supported:
// and, or, xor, not, eq, eq_left
assert_eq!(new_bitvec, new_bitvec2);
性能
在AMD Ryzen 7 3700X上与以下进行比较
$ cargo bench
bitvec_simd(this crate) time: [465.32 ns 468.04 ns 471.35 ns]
Found 7 outliers among 100 measurements (7.00%)
2 (2.00%) high mild
5 (5.00%) high severe
bit-vec 0.6 time: [1.9115 us 1.9129 us 1.9147 us]
change: [+0.0742% +0.2796% +0.5452%] (p = 0.01 < 0.05)
Change within noise threshold.
Found 4 outliers among 100 measurements (4.00%)
1 (1.00%) high mild
3 (3.00%) high severe
bitvec 1.0 time: [598.79 us 599.30 us 599.99 us]
change: [-0.1615% +0.1525% +0.3552%] (p = 0.30 > 0.05)
No change in performance detected.
Found 14 outliers among 100 measurements (14.00%)
1 (1.00%) high mild
13 (13.00%) high severe
bitvec_simd(this crate) with creation
time: [1.6427 us 1.6455 us 1.6491 us]
Found 2 outliers among 100 measurements (2.00%)
2 (2.00%) high severe
bit-vec 0.6 with creation
time: [2.4678 us 2.4696 us 2.4716 us]
change: [+1.1134% +1.3933% +1.6146%] (p = 0.00 < 0.05)
Performance has regressed.
Found 4 outliers among 100 measurements (4.00%)
3 (3.00%) high mild
1 (1.00%) high severe
bitvec 1.0 with creation
time: [220.12 us 220.81 us 221.71 us]
change: [-0.7438% -0.2211% +0.1436%] (p = 0.41 > 0.05)
No change in performance detected.
Found 9 outliers among 100 measurements (9.00%)
5 (5.00%) high mild
4 (4.00%) high severe
参考
该crate的一些代码来自 (https://github.com/horasal/bitvector_simd)
许可证
本项目受MIT许可证 (LICENSE-MIT)许可。
依赖项
~1.5MB
~32K SLoC