Current section
Files
Jump to
Current section
Files
README.md
# excrc32c [](https://hex.pm/packages/excrc32c) [](https://hexdocs.pm/excrc32c/)
A pure Elixir implementation of CRC32C.
**NOTE:** *Use a **NIF** if you need better performance, for example [`crc32cer`](https://hex.pm/packages/crc32cer).*
## Installation
The package can be installed by adding `excrc32c` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:excrc32c, "~> 0.2.0"}
]
end
```
### Usage
```elixir
iex> Excrc32c.crc32c("123456789")
3808858755
iex> Excrc32c.crc32c("DYB|O")
0
```
### Performance
Tested using [`benchee`](https://github.com/bencheeorg/benchee):
```
##### With input random 1 KB #####
Name ips average deviation median 99th %
0.2.0 340.31 K 2.94 μs ±33.59% 3.07 μs 4.10 μs
0.1.0 86.52 K 11.56 μs ±44.39% 10.24 μs 20.48 μs
Comparison:
0.2.0 340.31 K
0.1.0 86.52 K - 3.93x slower +8.62 μs
##### With input random 32 KB #####
Name ips average deviation median 99th %
0.2.0 10.83 K 92.33 μs ±50.87% 102.40 μs 102.40 μs
0.1.0 2.72 K 368.25 μs ±30.36% 409.60 μs 409.60 μs
Comparison:
0.2.0 10.83 K
0.1.0 2.72 K - 3.99x slower +275.92 μs
##### With input random 1 MB #####
Name ips average deviation median 99th %
0.2.0 345.23 2.90 ms ±7.88% 2.87 ms 4.77 ms
0.1.0 86.85 11.51 ms ±5.35% 11.37 ms 13.52 ms
Comparison:
0.2.0 345.23
0.1.0 86.85 - 3.97x slower +8.62 ms
```