Andrew Gallant 4a09815c87 bench: add criterion benchmarks
This represents an initial go at adding comprehensive criterion
benchmarks. We hit every public API function, and vary benchmarks based
on both corpus size and match frequency.

The point of this exercise is to establish a baseline on the status quo,
and make sure we don't introduce any major regressions after a
refactoring toward vendor intrinsics.
2018-09-17 16:31:52 -04:00
2018-09-17 16:31:52 -04:00
2016-04-02 18:39:40 -04:00
2018-08-25 10:43:58 -04:00
2018-09-17 16:31:52 -04:00
2018-09-17 16:31:52 -04:00
2018-01-01 09:52:58 -05:00
2018-08-25 10:22:11 -04:00
2015-06-11 19:00:02 -04:00
2015-06-11 19:00:02 -04:00
2015-06-11 19:00:02 -04:00
2015-06-11 19:00:02 -04:00
2018-03-03 10:17:31 -05:00
2015-06-11 19:00:02 -04:00
2015-06-11 19:00:02 -04:00

This crate provides a safe interface libc's memchr and memrchr. This crate also provides fallback implementations when either function is unavailable.

Build status Build status

Dual-licensed under MIT or the UNLICENSE.

Documentation

https://docs.rs/memchr

no_std

memchr links to the standard library by default, but you can disable the use_std feature if you want to use it in a #![no_std] crate:

[dependencies]
memchr = { version = "2", default-features = false }

Performance

On my system (Linux/amd64), memchr is about an order of magnitude faster than the more idiomatic haystack.iter().position(|&b| b == needle):

test iterator          ... bench:       5,280 ns/iter (+/- 13) = 1893 MB/s
test iterator_reversed ... bench:       5,271 ns/iter (+/- 7) = 1897 MB/s
test libc_memchr       ... bench:         202 ns/iter (+/- 0) = 49504 MB/s
test libc_memrchr      ... bench:         197 ns/iter (+/- 1) = 50761 MB/s
S
Description
提供在内存中搜索字符的支持。 | A Rust library that provides support for searching for characters in memory.
Readme 12 MiB
Languages
Rust 99.3%
Python 0.5%
Shell 0.2%