https://github.com/xmas7/bytecount
This uses the "hyperscreamingcount" algorithm by Joshua Landau to count bytes faster than anything else. The newlinebench repository has further benchmarks.
https://github.com/xmas7/bytecount
algorithm bytecount rust
Last synced: about 2 months ago
JSON representation
This uses the "hyperscreamingcount" algorithm by Joshua Landau to count bytes faster than anything else. The newlinebench repository has further benchmarks.
- Host: GitHub
- URL: https://github.com/xmas7/bytecount
- Owner: xmas7
- License: apache-2.0
- Created: 2022-09-06T00:07:07.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-09-06T00:08:11.000Z (over 2 years ago)
- Last Synced: 2025-02-01T09:28:04.709Z (4 months ago)
- Topics: algorithm, bytecount, rust
- Language: Rust
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.Apache2
Awesome Lists containing this project
README
# bytecount
Counting bytes really fast
[](https://travis-ci.org/llogiq/bytecount)
[](https://crates.io/crates/bytecount)
[](#License)This uses the "hyperscreamingcount" algorithm by Joshua Landau to count bytes
faster than anything else. The [newlinebench](/llogiq/newlinebench) repository
has further benchmarks.To use bytecount in your crate, if you have
[cargo-edit](/killercup/cargo-edit), just type `cargo add bytecount` in a
terminal with the crate root as the current path. Otherwise you can manually
edit your `Cargo.toml` to add `bytecount = 0.0.1` to your `[dependencies]`
section.In your crate root (`lib.rs` or `main.rs`, depending on if you are writing a
library or application), add `extern crate bytecount;`. Now you can simply use
`bytecount::count` as follows:```Rust
extern crate bytecount;fn main() {
let mytext = "some potentially large text, perhaps read from disk?";
let spaces = bytecount::count(mytext.as_bytes(), b' ');
..
}
```The algorithm is explained in depth
[here](https://llogiq.github.io/2016/09/27/count.html).