
I added a simple benchmark: https://github.com/basvandijk/case-insensitive/blob/hp/bench/bench.hs Unfortunately it shows some negative results: $ cabal configure --enable-benchmarks $ echo -n "performance" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor $ cabal build && \ dist/build/bench-case-insensitive/bench-case-insensitive -r comparison.csv && \ cat comparison.csv Resolving dependencies... Configuring case-insensitive-1.0... Building case-insensitive-1.0... Preprocessing library case-insensitive-1.0... Registering case-insensitive-1.0... Preprocessing benchmark 'bench-case-insensitive' for case-insensitive-1.0... Linking dist/build/bench-case-insensitive/bench-case-insensitive ... warming up estimating clock resolution... mean is 1.603349 us (320001 iterations) found 2111 outliers among 319999 samples (0.7%) 1568 (0.5%) high severe estimating cost of a clock call... mean is 38.94344 ns (14 iterations) found 2 outliers among 14 samples (14.3%) 2 (14.3%) high severe benchmarking no-class mean: 553.7687 us, lb 534.5956 us, ub 602.9884 us, ci 0.950 std dev: 139.3924 us, lb 23.04812 us, ub 252.4322 us, ci 0.950 found 18 outliers among 100 samples (18.0%) 6 (6.0%) high mild 12 (12.0%) high severe variance introduced by outliers: 96.768% variance is severely inflated by outliers benchmarking case-insensitive mean: 902.5999 us, lb 887.2243 us, ub 927.6100 us, ci 0.950 std dev: 98.40994 us, lb 66.76165 us, ub 138.9779 us, ci 0.950 found 13 outliers among 100 samples (13.0%) 4 (4.0%) high mild 9 (9.0%) high severe variance introduced by outliers: 82.094% variance is severely inflated by outliers Reference,Name,% faster than reference no-class,case-insensitive,-63 So turning foldCase into a method makes it 63% slower! Adding the following to Data.CaseInsensitive doesn't help: {-# SPECIALIZE mk :: ByteString -> CI ByteString #-} Inlining foldCase also doesn't help. Any ideas how to improve this? Bas