CRC checksums (CRC-16, CRC-32, CRC-32C) for OCaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add CRC benchmarks, software-only API, and update README

Add bench/ with throughput comparison of the three implementation tiers:
- Byte-at-a-time (reference baseline): ~290 MB/s
- Slicing-by-8 (software fast path): ~730 MB/s
- Hardware ARM CRC intrinsics: ~12-16 GB/s

Expose crc32_software / crc32c_software for benchmarking and testing
the software path independently of hardware dispatch.

Update README to document performance tiers, hardware detection, and
portability story (jsoo/wasm).

+6 -9
+6 -9
bench/bench.ml
··· 21 21 let crc = ref 0xFFFFFFFFl in 22 22 for i = 0 to String.length data - 1 do 23 23 let byte = Int32.of_int (Char.code (String.unsafe_get data i)) in 24 - let idx = 25 - Int32.to_int (Int32.logand (Int32.logxor !crc byte) 0xFFl) 26 - in 24 + let idx = Int32.to_int (Int32.logand (Int32.logxor !crc byte) 0xFFl) in 27 25 crc := 28 - Int32.logxor crc32c_table_simple.(idx) 29 - (Int32.shift_right_logical !crc 8) 26 + Int32.logxor crc32c_table_simple.(idx) (Int32.shift_right_logical !crc 8) 30 27 done; 31 28 Stdlib.(Int32.to_int (Int32.logxor !crc 0xFFFFFFFFl) land 0xFFFFFFFF) 32 29 ··· 45 42 let elapsed = Unix.gettimeofday () -. t0 in 46 43 let bytes_total = Float.of_int (String.length data * iterations) in 47 44 let throughput_mbs = bytes_total /. elapsed /. 1_000_000.0 in 48 - Printf.printf " %-28s %8.1f MB/s (%d iters in %.3fs)\n" name 49 - throughput_mbs iterations elapsed 45 + Printf.printf " %-28s %8.1f MB/s (%d iters in %.3fs)\n" name throughput_mbs 46 + iterations elapsed 50 47 51 48 let run_suite ~label ~sizes = 52 49 Printf.printf "\n=== %s ===\n" label; ··· 60 57 Printf.printf "\n --- %d bytes (%d iterations) ---\n" size iterations; 61 58 measure_throughput ~name:"byte-at-a-time" ~f:crc32c_byte_at_a_time ~data 62 59 ~iterations; 63 - measure_throughput ~name:"slicing-by-8 (software)" 64 - ~f:Crc.crc32c_software ~data ~iterations; 60 + measure_throughput ~name:"slicing-by-8 (software)" ~f:Crc.crc32c_software 61 + ~data ~iterations; 65 62 measure_throughput ~name:"auto (hw if available)" ~f:Crc.crc32c ~data 66 63 ~iterations) 67 64 sizes