Skip to content

Instantly share code, notes, and snippets.

@jozefg
Created July 25, 2017 04:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jozefg/297eb0b19deda396798bc0093679d17b to your computer and use it in GitHub Desktop.
Save jozefg/297eb0b19deda396798bc0093679d17b to your computer and use it in GitHub Desktop.
module Main where
import Criterion.Main
f1 :: [(Int, b)] -> [Int] -> Bool
f1 ps qs = all (\q -> all (\p -> fst p /= q) ps) qs
f2 :: [(Int, b)] -> [Int] -> Bool
f2 ps qs = all (flip all ps . flip ((/=) . fst)) qs
main :: IO ()
main = defaultMain
[ bgroup "f1"
[ bench "1" $ whnf (f1 [(1,1),(2,2),(3,3)]) [4, 6, 2]
, bench "2" $ whnf (f1 (replicate 1000 (1, 1))) (replicate 1000 1)
, bench "3" $ whnf (f1 (replicate 1000 (1, 1))) (replicate 1000 2)]
, bgroup "f2"
[ bench "1" $ whnf (f2 [(1,1),(2,2),(3,3)]) [4, 6, 2]
, bench "2" $ whnf (f2 (replicate 1000 (1, 1))) (replicate 1000 1)
, bench "3" $ whnf (f2 (replicate 1000 (1, 1))) (replicate 1000 2)]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment