1个不稳定版本
0.1.0 | 2022年1月19日 |
---|
#2194 在 数据结构 中
每月120 次下载
在 spdlog-rs 中使用
50KB
610 行
flexible-string
设计用于提高性能的堆栈堆灵活字符串。
FlexibleString
首先在 spdlog-rs 包中实现,该包将 spdlog-rs 的性能提高了约两倍(见 spdlog-rs 的基准测试)。现在它被提取为一个单独的包,供其他包使用。
有关更多详细信息,请参阅包 文档。
示例
您可以使用 FlexibleString
几乎像标准 String
一样。
use flexible_string::FlexibleString;
let mut string = FlexibleString::<250>::from("hello");
string.push(',');
string.push_str("world");
assert_eq!(string, "hello,world");
基准测试
在此存储库的根目录中运行 cargo +nightly bench
以进行基准测试。
以下结果是在 Windows 10 64 位
和 Intel i9-10900KF CPU @ 3.70GHz
上生成的。
-
FlexibleString
test bench_clone ... bench: 7 ns/iter (+/- 0) test bench_from_str ... bench: 6 ns/iter (+/- 0) test bench_push ... bench: 0 ns/iter (+/- 0) test bench_push_str ... bench: 0 ns/iter (+/- 0)
-
std::string::String
test bench_clone ... bench: 46 ns/iter (+/- 0) test bench_from_str ... bench: 40 ns/iter (+/- 0) test bench_push ... bench: 41 ns/iter (+/- 0) test bench_push_str ... bench: 39 ns/iter (+/- 0)
许可证
许可协议为以下之一
- Apache许可证版本2.0(《LICENSE-APACHE》或https://apache.ac.cn/licenses/LICENSE-2.0》)
- MIT许可证(《LICENSE-MIT》或http://opensource.org/licenses/MIT》)
任选其一。
贡献
除非您明确表示,否则根据Apache-2.0许可证定义的,您有意提交的任何贡献,都应如上所述双重许可,不得附加任何额外条款或条件。