ghc-mod/bench/Bench.hs

31 lines
786 B
Haskell
Raw Normal View History

2016-07-17 23:09:32 +00:00
import Criterion.Main
import GhcMod.Target
import GhcMod.Monad
import GhcMod.Types
2016-07-17 23:09:32 +00:00
import Dir
import System.IO.Temp
import System.Process hiding (env)
import Control.Monad
main = defaultMain [
env setup $ \dir -> bgroup "simple-cabal" [
bench "nop" $ whnfIO (simpleCabalNop dir 1)
, bench "nop10" $ whnfIO (simpleCabalNop dir 10)
]
]
setup = do
tdir <- createTempDirectory "/tmp" "ghc-mod-bench"
system $ "cp -rv \"bench/data/simple-cabal/\" \""++ tdir ++"\""
simpleCabalNop tdir 1 -- warmup dist/
return tdir
simpleCabalNop :: FilePath -> Int -> IO ()
simpleCabalNop dir n = withDirectory_ (dir </> "simple-cabal") $ do
_ <- runGhcModT defaultOptions $
forM_ [1..n] $ \_ -> do
runGmlT [Left "Main.hs"] (return ())
return ()