-- |
-- Tasty integration for vector benchmarks.
module Bench.Vector.Tasty
  ( VectorSize(..)
  , RandomSeed(..)
  ) where

import Test.Tasty.Options


-- | Size of vector used in benchmarks
newtype VectorSize = VectorSize Int

instance IsOption VectorSize where
  defaultValue :: VectorSize
defaultValue = Int -> VectorSize
VectorSize Int
2000000
  parseValue :: String -> Maybe VectorSize
parseValue = (Int -> VectorSize) -> Maybe Int -> Maybe VectorSize
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> VectorSize
VectorSize (Maybe Int -> Maybe VectorSize)
-> (String -> Maybe Int) -> String -> Maybe VectorSize
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe Int
forall a. Read a => String -> Maybe a
safeRead
  optionName :: Tagged VectorSize String
optionName = String -> Tagged VectorSize String
forall a. a -> Tagged VectorSize a
forall (f :: * -> *) a. Applicative f => a -> f a
pure String
"size"
  optionHelp :: Tagged VectorSize String
optionHelp = String -> Tagged VectorSize String
forall a. a -> Tagged VectorSize a
forall (f :: * -> *) a. Applicative f => a -> f a
pure String
"Size of vectors used in benchmarks"

-- | Random seed used for generation of the test data
newtype RandomSeed = RandomSeed Int

instance IsOption RandomSeed where
  defaultValue :: RandomSeed
defaultValue = Int -> RandomSeed
RandomSeed Int
42
  parseValue :: String -> Maybe RandomSeed
parseValue = (Int -> RandomSeed) -> Maybe Int -> Maybe RandomSeed
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> RandomSeed
RandomSeed (Maybe Int -> Maybe RandomSeed)
-> (String -> Maybe Int) -> String -> Maybe RandomSeed
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe Int
forall a. Read a => String -> Maybe a
safeRead
  optionName :: Tagged RandomSeed String
optionName = String -> Tagged RandomSeed String
forall a. a -> Tagged RandomSeed a
forall (f :: * -> *) a. Applicative f => a -> f a
pure String
"seed"
  optionHelp :: Tagged RandomSeed String
optionHelp = String -> Tagged RandomSeed String
forall a. a -> Tagged RandomSeed a
forall (f :: * -> *) a. Applicative f => a -> f a
pure String
"Random seed used for generation of the test data"