diff --git a/bench/Main.hs b/bench/Main.hs index 9de07b849..774faeaef 100644 --- a/bench/Main.hs +++ b/bench/Main.hs @@ -7,12 +7,17 @@ import Data.Monoid pyEval :: FilePath -> Benchmarkable pyEval = whnfIO . evaluatePythonFile . ("bench/bench-fixtures/python/" <>) - +rbEval :: FilePath -> Benchmarkable +rbEval = whnfIO . evaluateRubyFile . ("bench/bench-fixtures/ruby/" <>) main :: IO () -main = defaultMain [ - bgroup "python" [ bench "assignment" $ pyEval "simple-assignment.py" +main = defaultMain + [ bgroup "python" [ bench "assignment" $ pyEval "simple-assignment.py" , bench "function def" $ pyEval "function-definition.py" , bench "if + function calls" $ pyEval "if-statement-functions.py" ] + , bgroup "ruby" [ bench "assignment" $ rbEval "simple-assignment.rb" + , bench "function def" $ rbEval "function-definition.rb" + , bench "if + function calls" $ rbEval "if-statement-functions.rb" + ] ] diff --git a/bench/bench-fixtures/python/function-definition.py b/bench/bench-fixtures/python/function-definition.py index d86662294..5e687baf3 100644 --- a/bench/bench-fixtures/python/function-definition.py +++ b/bench/bench-fixtures/python/function-definition.py @@ -4,11 +4,11 @@ def a(): def c(d): e -def g(g, *h,): +def g(g, *h): i -def h(i=j): +def h(i=1): i -def i(j:str="default", **c): +def i(j="default", **c): j diff --git a/bench/bench-fixtures/python/if-statement-functions.py b/bench/bench-fixtures/python/if-statement-functions.py index be76ccf2f..b0354a090 100644 --- a/bench/bench-fixtures/python/if-statement-functions.py +++ b/bench/bench-fixtures/python/if-statement-functions.py @@ -2,11 +2,11 @@ def foo(): return "bipp" def bar(): return foo() -def baz(): return baz() +def baz(): return bar() def why(): return "elle" if True: - foo() + baz() else: why() diff --git a/bench/bench-fixtures/ruby/function-definition.rb b/bench/bench-fixtures/ruby/function-definition.rb new file mode 100644 index 000000000..275e25082 --- /dev/null +++ b/bench/bench-fixtures/ruby/function-definition.rb @@ -0,0 +1,19 @@ +def a() + "b" +end + +def c(d) + "e" +end + +def g(g_) + "i" +end + +def h(i=1) + i +end + +def i() + "j" +end diff --git a/bench/bench-fixtures/ruby/if-statement-functions.rb b/bench/bench-fixtures/ruby/if-statement-functions.rb new file mode 100644 index 000000000..52f7af32f --- /dev/null +++ b/bench/bench-fixtures/ruby/if-statement-functions.rb @@ -0,0 +1,21 @@ +def foo() + "bipp" +end + +def bar() + foo() +end + +def baz() + bar() +end + +def why() + return "elle" +end + +if true + baz() +else + why() +end diff --git a/bench/bench-fixtures/ruby/simple-assignment.rb b/bench/bench-fixtures/ruby/simple-assignment.rb new file mode 100644 index 000000000..d3c54e12d --- /dev/null +++ b/bench/bench-fixtures/ruby/simple-assignment.rb @@ -0,0 +1,5 @@ +foo = 2 +bar = foo +dang = 3 +song = dang +song