File: Common.hs

package info (click to toggle)
haskell-pipes 4.3.16-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 252 kB
  • sloc: haskell: 1,969; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 777 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Common (commonMain) where

import Criterion.Main (Benchmark, runMode)
import Criterion.Main.Options as Criterion
import Data.Maybe (fromMaybe)
import Data.Monoid
import Options.Applicative

commonMain :: Int                    -- ^ default maximum data size
           -> (Int -> [Benchmark])   -- ^ the benchmarks to run
           -> IO ()
commonMain mdMax bench = do
    (maybeNewMax, critMode) <- execParser $ info (helper <*> options) mempty
    runMode critMode $ bench (fromMaybe mdMax maybeNewMax)

options :: Parser (Maybe Int, Criterion.Mode)
options =
    (,) <$> optional (option auto (help "benchmark maximum data size"
                                   <> metavar "N" <> short 'i'  <> long "imax"))
        <*> Criterion.parseWith Criterion.defaultConfig