mirror of
https://github.com/Lysxia/generic-random.git
synced 2024-10-26 09:41:05 +03:00
Turn tour-example into benchmark
This commit is contained in:
parent
1b5b102a79
commit
1c7d6ef883
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user