Move the Generator program into a proper benchmark
This commit is contained in:
parent
85edb2c74c
commit
2f933aec20
2 changed files with 23 additions and 7 deletions
|
@ -49,12 +49,14 @@ executable sjw
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
ghc-options: -Wall
|
ghc-options: -Wall
|
||||||
|
|
||||||
executable generator
|
benchmark big-src
|
||||||
main-is: tests/Generator.hs
|
type: exitcode-stdio-1.0
|
||||||
build-depends: base >=4.11 && <4.13
|
main-is: benchmark/Main.hs
|
||||||
|
build-depends: base >= 4.9 && <4.15
|
||||||
, directory
|
, directory
|
||||||
, filepath
|
, filepath
|
||||||
, random
|
, random
|
||||||
, SJW
|
, SJW
|
||||||
|
, time
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
ghc-options: -Wall
|
ghc-options: -Wall
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
{-# LANGUAGE NamedFieldPuns #-}
|
{-# LANGUAGE NamedFieldPuns #-}
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
import SJW (Path(..))
|
import SJW (Path(..), compile, source, sourceCode)
|
||||||
import Control.Monad (foldM)
|
import Control.Monad (foldM)
|
||||||
import System.Directory (createDirectoryIfMissing)
|
import Data.Time.Clock (diffUTCTime, getCurrentTime)
|
||||||
|
import System.Directory (createDirectoryIfMissing, doesDirectoryExist)
|
||||||
import System.FilePath ((</>), (<.>))
|
import System.FilePath ((</>), (<.>))
|
||||||
import System.Random (randomRIO)
|
import System.Random (randomRIO)
|
||||||
import Text.Printf (printf)
|
import Text.Printf (printf)
|
||||||
|
@ -26,7 +27,7 @@ addDependency path fakeModule = fakeModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
destDir :: FilePath
|
destDir :: FilePath
|
||||||
destDir = "tests/giant"
|
destDir = "/tmp/SJW-benchmark/giant"
|
||||||
|
|
||||||
generateCode :: FakeModule -> String
|
generateCode :: FakeModule -> String
|
||||||
generateCode (FakeModule {dependencies}) = unlines $
|
generateCode (FakeModule {dependencies}) = unlines $
|
||||||
|
@ -80,4 +81,17 @@ writeFakeModule fakeModule@(FakeModule {name = Path components}) =
|
||||||
writeFile (directory </> head fileName <.> "js") $ generateCode fakeModule
|
writeFile (directory </> head fileName <.> "js") $ generateCode fakeModule
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = generateDAG 10000 10 (50, 100) >>= mapM_ writeFakeModule
|
main = do
|
||||||
|
directoryExists <- doesDirectoryExist destDir
|
||||||
|
if not directoryExists
|
||||||
|
then do
|
||||||
|
createDirectoryIfMissing True destDir
|
||||||
|
generateDAG 10000 10 (50, 100) >>= mapM_ writeFakeModule
|
||||||
|
else return ()
|
||||||
|
start <- getCurrentTime
|
||||||
|
maybe (return ()) (\_ -> return ()) =<< sourceCode =<< compile (source [destDir])
|
||||||
|
end <- getCurrentTime
|
||||||
|
mapM_ putStrLn [
|
||||||
|
"Compiled 10k modules in " ++ show (diffUTCTime end start)
|
||||||
|
, "Left the fake project in " ++ destDir ++ " if you want to poke around"
|
||||||
|
]
|
Loading…
Reference in a new issue