diff --git a/examples/generic-random-examples.cabal b/examples/generic-random-examples.cabal index 71dedc9..18c3bde 100644 --- a/examples/generic-random-examples.cabal +++ b/examples/generic-random-examples.cabal @@ -37,3 +37,15 @@ executable tour-example text, generic-random default-language: Haskell2010 + +executable tour-bench + main-is: tour.hs + ghc-options: -O2 + ghc-options: -ddump-simpl -dsuppress-all -dno-suppress-module-prefixes + cpp-options: -DBENCHMODE + build-depends: + base, + QuickCheck, + text, + generic-random + default-language: Haskell2010 diff --git a/examples/tour.hs b/examples/tour.hs index 832a3a0..67ed45a 100644 --- a/examples/tour.hs +++ b/examples/tour.hs @@ -1,5 +1,6 @@ -- Just another toy example +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleInstances #-} @@ -31,6 +32,8 @@ instance Arbitrary MyType where -- , (4, ThreeThings <$> (Just <$> arbitrary) <*> arbitrary <*> arbitrary) -- ] +main :: IO () +#ifndef BENCHMODE main = do -- Print some examples sample (arbitrary @MyType) @@ -39,6 +42,15 @@ main = do quickCheck $ \case ThreeThings Nothing _ _ -> False _ -> True +#else +-- Quick and dirty benchmark +main = do + xs <- generate (replicateM 1000000 (arbitrary @MyType)) + go xs + where + go [] = print () + go (x : xs) = x `seq` go xs +#endif -- Ew. Sorry. instance Show a => Show (Bool -> a) where