Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support for dual GHC/lcvm benchmarks.

Running a benchmark no longer requires manual modification.  The two
versions are now selected via the preprocessor.  To compile for
benchmarking with GHC use -DBENCH_GHC.
  • Loading branch information...
commit 19d93d7fe50bb2fdcee6d7f496301a853271d3bb 1 parent ae501db
@nominolo authored
View
4 Makefile.in
@@ -350,6 +350,10 @@ clean-bytecode:
.PHONY: gtest
gtest: $(GTEST_A)
+bench-ghc/%: tests/Bench/%.hs
+ @mkdir -p bench-ghc
+ $(HC) -O2 -fforce-recomp -DBENCH_GHC $(BENCH_HC_OPTS) -rtsopts -o $@ $<
+
-include $(SRCS:%.c=$(DEPDIR)/%.P)
-include $(UTILSRCS:%.cc=$(DEPDIR)/%.P)
-include $(DEPDIR)/vm/unittest.P
View
17 tests/Bench/SumFromTo1.hs
@@ -1,13 +1,22 @@
-{-# LANGUAGE NoImplicitPrelude, BangPatterns, MagicHash #-}
+{-# LANGUAGE NoImplicitPrelude, BangPatterns, MagicHash, CPP #-}
-- RUN: %bc_vm_chk
-- CHECK: @Result@ IND -> GHC.Bool.True`con_info
+#ifdef BENCH_GHC
+import Prelude ( print )
+#else
module Bench.SumFromTo1 where
+#endif
import GHC.Prim
import GHC.Bool
import GHC.Types
+#ifdef USE_NOINLINE
{-# NOINLINE enumFromTo #-}
+{-# NOINLINE sum_aux #-}
+{-# NOINLINE root #-}
+#endif
+
enumFromTo :: Int -> Int -> [Int]
enumFromTo from@(I# m) to@(I# n) =
if m ># n then [] else
@@ -22,7 +31,6 @@ one = I# 1#
sum :: [Int] -> Int
sum l = sum_aux (I# 0#) l
-{-# NOINLINE sum_aux #-}
sum_aux :: Int -> [Int] -> Int
sum_aux !acc [] = acc
sum_aux !(I# a) (I# x:xs) = sum_aux (I# (a +# x)) xs
@@ -39,7 +47,6 @@ succInt (I# m) = I# (m +# 1#)
eqInt :: Int -> Int -> Bool
eqInt (I# m) (I# n) = m ==# n
-{-# NOINLINE root #-}
root upper =
let !l = sum (enumFromTo one upper) in
(l `plusInt` l) `eqInt` (upper `timesInt` (succInt upper))
@@ -47,3 +54,7 @@ root upper =
test = root (I# 100#)
bench = root (I# 200000000#)
+
+#ifdef BENCH_GHC
+main = print bench
+#endif
View
18 tests/Bench/SumSquare1.hs
@@ -1,13 +1,23 @@
-{-# LANGUAGE NoImplicitPrelude, BangPatterns, MagicHash #-}
+{-# LANGUAGE NoImplicitPrelude, BangPatterns, MagicHash, CPP #-}
-- RUN: %bc_vm_chk
-- CHECK: @Result@ IND -> GHC.Bool.True`con_info
+#ifdef BENCH_GHC
+import Prelude ( print )
+#else
module Bench.SumSquare1 where
+#endif
import GHC.Prim
import GHC.List
import GHC.Base
import GHC.Num
+#ifdef USE_NOINLINE
+{-# NOINLINE enumFromTo'Int #-}
+{-# NOINLINE sum_aux #-}
+{-# NOINLINE root #-}
+#endif
+
enumFromTo'Int :: Int -> Int -> [Int]
enumFromTo'Int from@(I# m) to@(I# n) =
if m ># n then [] else
@@ -28,3 +38,9 @@ root x = sum [ I# (a# *# b#)
, I# b# <- enumFromTo'Int a x ]
test = root 20 == 23485
+
+bench = root 15000
+
+#ifdef BENCH_GHC
+main = print bench
+#endif
Please sign in to comment.
Something went wrong with that request. Please try again.