Skip to content

Commit

Permalink
feat: add performance chart
Browse files Browse the repository at this point in the history
  • Loading branch information
polazarus committed Aug 16, 2023
1 parent 0045c05 commit 54b9941
Show file tree
Hide file tree
Showing 6 changed files with 531 additions and 77 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ cargo +nightly miri test --target i686-unknown-linux-gnu

## 📦 Similar crates

`#[non-exhaustive]`
`#[non_exhaustive]`

| Name | Thread-safe cheap-clone | Local cheap-clone | Inline | Cheap slice | Bytes | Cow<'a> | Comment |
| ---- | ----------- | ----- | ------ | ------ | ----- | ---- | :------ |
| `hipstr` | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | obviously!
| [`arcstr`](https://github.com/thomcc/arcstr) | 🟢* |||** ||| *use a custom `Arc`, **heavy slice (with dedicated substring type) |
| [`arcstr`](https://github.com/thomcc/arcstr) | 🟢* |||** ||| *use a custom thin `Arc`, **heavy slice (with dedicated substring type) |
| [`flexstr`](https://github.com/nu11ptr/flexstr) | 🟢* | 🟢 | 🟢 |||| *use an `Arc<str>` instead of an `Arc<String>` (remove one level of indirection but use fat pointers) |
| [`imstr`](https://github.com/xfbs/imstr) | 🟢 | 🟢 || 🟢 ||| |
| [`faststr`](https://github.com/volo-rs/faststr) | 🟢 || 🟢 | 🟢 ||| zero-doc with complex API |
Expand All @@ -118,12 +118,20 @@ cargo +nightly miri test --target i686-unknown-linux-gnu
| [`smallstr`](https://github.com/murarth/smallstr) ||| 🟢 |||| |
| [`smol_str`](https://github.com/rust-analyzer/smol_str) ||| 🟢* |||| *but only inline string, here for reference |

skipping specialized string types like [`tinystr`](https://github.com/unicode-org/icu4x) (ASCII-only, bounded), or bstr, or bytestring, or
skipping specialized string types like [`tinystr`](https://github.com/unicode-org/icu4x) (ASCII-only, bounded), or bstr, or bytestring, or...

In short, `HipStr`, one string type to rule them all
In short, `HipStr`, one string type to rule them all 😉

[![How standards proliferate](https://imgs.xkcd.com/comics/standards.png)](https://xkcd.com/927/)

## 🏎️ Performances

While speed is not the main motivator for `hipstr`, it seems to be doing OK on that front.

On my i7-8550U, under Arch Linux over Windows 11/WSL 2 (yeah I know 😅), the creation of a `HipStr` from a slice is competitive with other crates and the `std`:

![string-comparison/chart.svg](string-comparison/chart.svg)

## 📖 Author and licenses

For now, just me PoLazarus 👻 \
Expand Down
19 changes: 19 additions & 0 deletions string-comparison/chart.gnu
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
set style data lines
set datafile separator comma
set datafile columnheaders

set key autotitle columnheader
set title "string construction from string slice (non-borrowing)"
set ylabel "time (nanoseconds)"
set xlabel "string length (bytes)"
set key outside right top vertical box
set logscale x 2

set output "chart.png"
set terminal pngcairo size 1200,800 noenhanced font "Liberation Sans,14" linewidth 1.5

plot for [i=2:*] 'data.csv' using 1:i with linespoints

set output "chart.svg"
set terminal svg size 1200,800 noenhanced font "Arial,Helvetica,14" linewidth 1.5 background rgb "white"
replot
Binary file added string-comparison/chart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 54b9941

Please sign in to comment.