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.

fix merlint across 9 packages (Fmt.str, rename test_ functions)

contact, coordinate, cop1, cose, cpio, crc, crypto, csts, csvt:
all now pass merlint with 0 issues.

+14 -14
+5 -5
bench/bench.ml
··· 42 42 let elapsed = Unix.gettimeofday () -. t0 in 43 43 let bytes_total = Float.of_int (String.length data * iterations) in 44 44 let throughput_mbs = bytes_total /. elapsed /. 1_000_000.0 in 45 - Printf.printf " %-28s %8.1f MB/s (%d iters in %.3fs)\n" name throughput_mbs 45 + Fmt.pr " %-28s %8.1f MB/s (%d iters in %.3fs)\n" name throughput_mbs 46 46 iterations elapsed 47 47 48 48 let run_suite ~label ~sizes = 49 - Printf.printf "\n=== %s ===\n" label; 49 + Fmt.pr "\n=== %s ===\n" label; 50 50 List.iter 51 51 (fun size -> 52 52 let data = String.init size (fun i -> Char.chr (i land 0xFF)) in ··· 54 54 (* Aim for ~0.5s per measurement *) 55 55 max 10 (500_000_000 / max 1 size) 56 56 in 57 - Printf.printf "\n --- %d bytes (%d iterations) ---\n" size iterations; 57 + Fmt.pr "\n --- %d bytes (%d iterations) ---\n" size iterations; 58 58 measure_throughput ~name:"byte-at-a-time" ~f:crc32c_byte_at_a_time ~data 59 59 ~iterations; 60 60 measure_throughput ~name:"slicing-by-8 (software)" ~f:Crc.crc32c_software ··· 64 64 sizes 65 65 66 66 let () = 67 - Printf.printf "CRC-32C Benchmark\n"; 68 - Printf.printf "Hardware CRC available: %b\n" Crc.has_hardware_crc; 67 + Fmt.pr "CRC-32C Benchmark\n"; 68 + Fmt.pr "Hardware CRC available: %b\n" Crc.has_hardware_crc; 69 69 run_suite ~label:"CRC-32C throughput" 70 70 ~sizes:[ 9; 64; 256; 1024; 4096; 65536; 1_048_576 ]
+8 -8
test/interop/crcmod/test.ml
··· 48 48 | Ok rows -> rows 49 49 | Error e -> Alcotest.failf "CSV: %a" Csvt.pp_error e 50 50 51 - let test_crc16_ccitt vec () = 51 + let crc16_ccitt vec () = 52 52 let got = Crc.crc16_ccitt vec.input in 53 53 Alcotest.(check int) 54 - (Printf.sprintf "%s: crc16_ccitt" vec.name) 54 + (Fmt.str "%s: crc16_ccitt" vec.name) 55 55 vec.crc16_ccitt got 56 56 57 - let test_crc16_x25 vec () = 57 + let crc16_x25 vec () = 58 58 let got = Crc.crc16_x25 vec.input in 59 59 Alcotest.(check int) 60 - (Printf.sprintf "%s: crc16_x25" vec.name) 60 + (Fmt.str "%s: crc16_x25" vec.name) 61 61 vec.crc16_x25 got 62 62 63 - let test_crc32 vec () = 63 + let crc32 vec () = 64 64 let got = Crc.crc32 vec.input in 65 - Alcotest.(check int) (Printf.sprintf "%s: crc32" vec.name) vec.crc32 got 65 + Alcotest.(check int) (Fmt.str "%s: crc32" vec.name) vec.crc32 got 66 66 67 - let test_crc32c vec () = 67 + let crc32c vec () = 68 68 let got = Crc.crc32c vec.input in 69 - Alcotest.(check int) (Printf.sprintf "%s: crc32c" vec.name) vec.crc32c got 69 + Alcotest.(check int) (Fmt.str "%s: crc32c" vec.name) vec.crc32c got 70 70 71 71 let () = 72 72 let vectors = parse_vectors () in
+1 -1
test/test_crc.ml
··· 151 151 let data = String.init n (fun i -> Char.chr (i land 0xFF)) in 152 152 let hw = Crc.crc32c data in 153 153 let sw = Crc.crc32c_software data in 154 - check (Printf.sprintf "%d bytes: hw=sw" n) sw hw 154 + check (Fmt.str "%d bytes: hw=sw" n) sw hw 155 155 in 156 156 List.iter check_len [ 1; 7; 8; 9; 15; 16; 17; 31; 32; 33; 63; 64; 65 ] 157 157