diff --git a/bench/Bench/ApplyMerge.hs b/bench/Bench/ApplyMerge.hs index 01c6a5d..447ba60 100644 --- a/bench/Bench/ApplyMerge.hs +++ b/bench/Bench/ApplyMerge.hs @@ -9,6 +9,7 @@ import ApplyMerge.IntMap qualified import ApplyMerge.IntSet qualified import ApplyMerge.MergeAll qualified import Data.Function ((&)) +import Data.List (foldl') import Data.List.Ordered (minus) import Test.Tasty.Bench (Benchmark, bench, bgroup, nf) @@ -55,7 +56,7 @@ benchmarks = composites :: [Int] composites = applyMerge (\p j -> p * (p + j)) primes [zero ..] - in sum (takeWhile (<= n) primes) + in foldl' (+) 0 (takeWhile (<= n) primes) ] type ApplyMerge = forall a b c. (Ord c) => (a -> b -> c) -> [a] -> [b] -> [c] @@ -68,7 +69,7 @@ funcToCollapse f applyMerge n = let one = (n `quot` maxBound) + 1 in applyMerge f [one ..] [one ..] & take n - & sum + & foldl' (+) 0 collapseToBenchmark :: String -> (ApplyMerge -> Int -> Int) -> Benchmark collapseToBenchmark name collapse = bgroup name (map mkBench [1 .. 6])