Skip to content

Commit

Permalink
Add note about performance
Browse files Browse the repository at this point in the history
  • Loading branch information
simonask committed Feb 4, 2024
1 parent 047bb8d commit 8f6ce4b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@ drop-in replacement. The shape of the API is idiomatic Rust, and while it is
possible to emulate the C API using this library, supporting this use case is
not a priority. Use `unsafe-libyaml` if that is what you need.

### Performance

Performance is largely on par with `unsafe-libyaml`. No significant effort has
been put into optimizing this library, beyond just choosing the most
straightforward ways to reasonably port concepts from the C-like code.

See
[`benches/bench.rs`](https://github.com/simonask/libyaml-safer/benches/bench.rs)
for a very simple benchmark dealing with a very large (~700 KiB) YAML document.
On my machine (Ryzen 9 3950X) the parser from this library is slightly slower
and the emitter is slightly faster, but both within about ~1ms of their unsafe
counterparts. Run `cargo bench` to test on your machine.

If there is demand, there are clear paths forward to optimize the parser. For
example, due to it being ported directly from unsafe C-like code doing pointer
arithmetic, it performs a completely unreasonable number of bounds checks for
each input byte.

## License

<a href="LICENSE-MIT">MIT license</a>, same as unsafe-libyaml and libyaml.

0 comments on commit 8f6ce4b

Please sign in to comment.