-
Notifications
You must be signed in to change notification settings - Fork 9
Performance
Zibi Braniecki edited this page Oct 28, 2019
·
12 revisions
Performance has been tested on MacBook Pro 2017, using Rust 1.38 and tinystr 0.3.2.
All benchmarks use black_box
wrapper.
Char Limit | String | TinyStr4 | TinyStr8 | TinyStr16 |
---|---|---|---|---|
4 | 1.078 us | 31.51 ns | 98.67 ns | 115.47 ns |
8 | 1.009 us | 101.77 ns | 119.43 ns | |
16 | 1.081 us | 122.64 ns |
Char Limit | String | TinyStr4 | TinyStr8 | TinyStr16 |
---|---|---|---|---|
4 | 1.088 us | 20.70 ns | 26.93 ns | 32.07 ns |
8 | 1.105 us | 27.00 ns | 31.60 ns | |
16 | 1.238 us | 31.72 ns |
Char Limit | String | TinyStr4 | TinyStr8 | TinyStr16 |
---|---|---|---|---|
4 | 1.087 us | 20.79 ns | 27.36 ns | 33.85 ns |
8 | 1.097 us | 27.14 ns | 33.22 ns | |
16 | 1.109 us | 33.19 ns |
Char Limit | String | TinyStr4 | TinyStr8 | TinyStr16 |
---|---|---|---|---|
4 | 1.139 us | 23.80 ns | 26.90 ns | 42.27 ns |
8 | 1.165 us | 27.01 ns | 42.39 ns | |
16 | 1.173 us | 42.15 ns |
Char Limit | String | TinyStr4 | TinyStr8 | TinyStr16 |
---|---|---|---|---|
4 | 42.10 ns | 21.45 ns | 30.64 ns | 34.90 ns |
8 | 52.19 ns | 30.66 ns | 35.05 ns | |
16 | 78.00 us | 34.95 ns |
Char Limit | String | TinyStr4 | TinyStr8 | TinyStr16 |
---|---|---|---|---|
4 | 659.48 ns | 85.80 ns | 86.07 ns | 141.57 ns |
8 | 433.12 ns | 90.79 ns | 146.25 ns | |
16 | 380.83 us | 147.61 ns |
Crate | Version | Notes |
---|---|---|
istring | 0.1.13 |
IString::from and Rust Nightly has been used |
smol_str | 0.1.15 |
SmolStr::from has been used |
smallstr | 0.1.0 |
FromStr with <[u8; 4/8/16]> has been used |
arraystring | 0.3.0 |
FromStr with U4/U8/U16 has been used |
Char Limit | SmolStr | smallstr | ArrayString | istring | String | TinyStr4 | TinyStr8 | TinyStr16 |
---|---|---|---|---|---|---|---|---|
4 | 318.70 ns | 184.02 ns | 109.26 ns | 130.07 ns | 1.078 us | 31.51 ns | 98.67 ns | 115.47 ns |
8 | 309.23 ns | 185.24 ns | 133.08 ns | 131.42 ns | 1.009 us | 101.77 ns | 119.43 ns | |
16 | 307.28 ns | 248.08 ns | 172.67 ns | 132.88 ns | 1.081 us | 122.64 ns |
Char Limit | SmolStr | smallstr | ArrayString | istring | String | TinyStr4 | TinyStr8 | TinyStr16 |
---|---|---|---|---|---|---|---|---|
4 | 1.584 us | 1.053 us | 743.74 ns | 1.169 us | 659.48 ns | 85.80 ns | 86.07 ns | 141.57 ns |
8 | 1.343 us | 706.87 ns | 498.56 ns | 870.97 ns | 433.12 ns | 90.79 ns | 146.25 ns | |
16 | 1.190 us | 727.96 ns | 467.14 ns | 724.64 ns | 380.83 ns | 147.61 ns |
For other operations, SmolStr
, ArrayString
, smallstr
and istring
have performance comparable to String
.