#string #stack #inline #sso #inlinable

flexible-string

设计用于提高性能的堆栈堆灵活字符串

1个不稳定版本

0.1.0 2022年1月19日

#2194数据结构

Download history 12/week @ 2024-04-07 67/week @ 2024-04-14 34/week @ 2024-05-12 16/week @ 2024-05-19 96/week @ 2024-05-26 145/week @ 2024-06-09 20/week @ 2024-06-16 83/week @ 2024-06-23 81/week @ 2024-06-30 9/week @ 2024-07-14 30/week @ 2024-07-21

每月120 次下载
spdlog-rs 中使用

MIT/Apache

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 64Intel 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许可证定义的,您有意提交的任何贡献,都应如上所述双重许可,不得附加任何额外条款或条件。

无运行时依赖