8 个版本 (3 个稳定版)
1.1.1 | 2023年4月28日 |
---|---|
1.1.0 | 2020年12月27日 |
1.0.0 | 2019年11月7日 |
0.1.4 | 2018年7月12日 |
0.1.2 | 2017年3月31日 |
#40 in 性能分析
每月 1,991 次下载
被 9 crates 使用
20KB
208 行
这是一个轻量级基准测试库,
- 使用线性回归来筛选掉恒定误差的来源;
- 处理必须修改某些状态的基准测试;
- API 非常简单!
use easybench::{bench,bench_env};
// Simple benchmarks are performed with `bench`.
println!("fib 200: {}", bench(|| fib(200) ));
println!("fib 500: {}", bench(|| fib(500) ));
// If a function needs to mutate some state, use `bench_env`.
println!("reverse: {}", bench_env(vec![1,2,3], |xs| xs.reverse()));
println!("sort: {}", bench_env(vec![1,2,3], |xs| xs.sort()));
运行上述代码将产生以下结果
fib 200: 38 ns (R²=1.000, 26053498 iterations in 155 samples)
fib 500: 109 ns (R²=1.000, 9131585 iterations in 144 samples)
reverse: 3 ns (R²=0.998, 23684997 iterations in 154 samples)
sort: 3 ns (R²=0.999, 23684997 iterations in 154 samples)
许可证
根据以下任一许可证授权:
- Apache 许可证 2.0 版,(LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT 许可证 (LICENSE-MIT 或 http://opensource.org/licenses/MIT)
任选其一。
贡献
除非您明确声明,否则根据 Apache-2.0 许可证定义的,您提交给作品包含的任何贡献都将根据上述方式双许可,不附加任何额外条款或条件。