1
1
mirror of https://github.com/github/semantic.git synced 2024-12-18 04:11:48 +03:00
semantic/bench/Main.hs

30 lines
1.2 KiB
Haskell
Raw Normal View History

2018-03-08 03:34:20 +03:00
module Main where
import Criterion.Main
import Semantic.Util
import Data.Monoid
import Control.Monad
2018-03-08 03:34:20 +03:00
2018-03-08 21:18:36 +03:00
-- We use `fmap show` to ensure that all the parts of the result of evaluation are
-- evaluated themselves. While an NFData instance is the most morally correct way
-- to do this, I'm reluctant to add NFData instances to every single datatype in the
-- project—coercing the result into a string will suffice, though it throws off the
-- memory allocation results a bit.
2018-03-08 03:34:20 +03:00
pyEval :: FilePath -> Benchmarkable
pyEval = whnfIO . fmap show . evalPythonProject . ("bench/bench-fixtures/python/" <>)
2018-03-08 03:34:20 +03:00
2018-03-08 03:47:23 +03:00
rbEval :: FilePath -> Benchmarkable
rbEval = whnfIO . fmap show . evalRubyProject . ("bench/bench-fixtures/ruby/" <>)
2018-03-08 03:34:20 +03:00
main :: IO ()
2018-03-08 03:47:23 +03:00
main = defaultMain
[ bgroup "python" [ bench "assignment" $ pyEval "simple-assignment.py"
2018-03-12 17:51:07 +03:00
, bench "function def" $ pyEval "function-definition.py"
, bench "if + function calls" $ pyEval "if-statement-functions.py"
]
2018-03-08 03:47:23 +03:00
, bgroup "ruby" [ bench "assignment" $ rbEval "simple-assignment.rb"
, bench "function def" $ rbEval "function-definition.rb"
, bench "if + function calls" $ rbEval "if-statement-functions.rb"
]
2018-03-08 03:34:20 +03:00
]