2个版本

0.2.1 2020年4月19日
0.2.0 2020年4月16日

#954数据结构

MIT 许可证

130KB
3K SLoC

pvec-rs

GitHub Workflow Status Crates.io API

基于RRB-Tree的Rust持久向量实现,受Niko Matsakis博客文章启发 - 在Rust中,普通向量是值。该项目提供了一个通用、性能良好的持久向量,包括高效的克隆、连接和拆分等操作。

向量类型之一 - PVec,探索了从标准向量开始,仅在克隆时转换为树表示,以提供最佳性能的想法。pvec-rs提供的方法的API与标准向量相同,减少了使用库的摩擦。另一个显著特点是支持Rayon

库的性能评估可以在技术报告中找到。PVec可在crates.io上找到,API文档可在docs.rs上找到。

示例

PVec的使用演示

extern crate pvec;

use pvec::PVec;

fn example_pvec(size: usize) {
    let mut vec = PVec::new();
    // ^ backed by the standard vector internally

    for i in 0..size {
        vec.push(i);
    }

    let cln = vec.clone();
    // ^ transitions to RrbVec internally,
    // with consequent clones that cost O(1)

    let res: PVec<usize> = vec.into_par_iter()
        .map(|it| it + 1)
        .collect();
    // ^ processing vector in parallel and
    // collecting results
}

基准测试

运行时

运行时基准测试分为顺序组和并行组。运行基准测试的框架是criterion,如果您已预安装gnuplot,它可以生成带有图表的HTML报告。

# running all sequential benches
cargo bench

# running parallel benches
cargo bench --features=arc,rayon_iter

报告可以在target/criterion/report/index.html找到。为了避免运行数小时的基准测试,传递--sample-size=10选项以减少样本数量。

内存

使用自定义二进制crate - benches-mem 测量内存占用。此二进制通过time实用工具运行benches crate中的基准测试,捕获进程的峰值内存使用量。报告放置在target/release/report。请注意,这些基准测试目前只能在macOS上执行,因为time在mac和linux上的行为不同。

cd benches-mem && sh bench.sh

许可证

MIT License

Copyright (c) 2020 Araz Abishov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

依赖项

~0–530KB
~11K SLoC