File: Report.hs

package info (click to toggle)
haskell-criterion 1.6.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 360 kB
  • sloc: haskell: 1,891; javascript: 811; makefile: 3
file content (32 lines) | stat: -rw-r--r-- 989 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{-# LANGUAGE RecordWildCards #-}
module Main (main) where

import System.Exit (exitSuccess, exitFailure)
import System.IO (hPutStrLn, stderr)

import Criterion.IO (readJSONReports)
import Criterion.Main (defaultConfig)
import Criterion.Monad (withConfig)
import Criterion.Report (report)
import Criterion.Types (Config(reportFile, template))

import Options

main :: IO ()
main = do
    cmd <- parseCommandLine
    case cmd of
        Version -> putStrLn versionInfo >> exitSuccess
        Report{..} -> do
            let config = defaultConfig
                  { reportFile = Just outputFile
                  , template = templateFile
                  }

            res <- readJSONReports jsonFile
            case res of
                Left err -> do
                    hPutStrLn stderr $ "Error reading file: " ++ jsonFile
                    hPutStrLn stderr $ "  " ++ show err
                    exitFailure
                Right (_,_,rpts) -> withConfig config $ report rpts