Zstd compression in pure OCaml
1(* Test FSE compression with larger blocks *)
2
3let test_large_block size =
4 (* Create compressible data - repetitive pattern *)
5 let data = String.init size (fun i -> Char.chr ((i / 4) mod 256)) in
6 try
7 let compressed = Zstd.compress data in
8 let decompressed = Zstd.decompress_exn compressed in
9 if decompressed = data then
10 Printf.printf "Size %d: OK (compressed to %d, ratio %.2f%%)\n"
11 size (String.length compressed)
12 (100.0 *. float_of_int (String.length compressed) /. float_of_int size)
13 else
14 Printf.printf "Size %d: MISMATCH!\n" size
15 with e ->
16 Printf.printf "Size %d: FAILED - %s\n" size (Printexc.to_string e)
17
18let () =
19 List.iter test_large_block [100; 1000; 4000; 8000; 8192; 10000; 16000; 32000; 65536; 131072]