on master help sign in
Add fusion checking code in Data.Fold benchmark
9e8c35dHarendra Kumar
benchmark/Streamly/Benchmark/Data/Fold.hs+25−1
@@ -12,6 +12,11 @@
12{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}
12{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}
13{-# OPTIONS_GHC -Wno-orphans #-}
13{-# OPTIONS_GHC -Wno-orphans #-}
14
14
15+#undef FUSION_CHECK
16+#ifdef FUSION_CHECK
17+{-# OPTIONS_GHC -ddump-simpl -ddump-to-file -dsuppress-all #-}
18+#endif
19+
15module Main (main) where
20module Main (main) where
16
21
17import Control.DeepSeq (NFData(..))
22import Control.DeepSeq (NFData(..))
@@ -502,7 +507,9 @@ o_n_heap_serial value =
502-------------------------------------------------------------------------------
507-------------------------------------------------------------------------------
503
508
504main :: IO ()
509main :: IO ()
510+main = do
511+#ifndef FUSION_CHECK
505−main = runWithCLIOpts defaultStreamSize allBenchmarks
512+ runWithCLIOpts defaultStreamSize allBenchmarks
506
513
507 where
514 where
508
515
@@ -515,3 +522,20 @@ main = runWithCLIOpts defaultStreamSize allBenchmarks
515 , bgroup (o_n_space_prefix moduleName) (o_n_space_serial value)
522 , bgroup (o_n_space_prefix moduleName) (o_n_space_serial value)
516 , bgroup (o_n_heap_prefix moduleName) (o_n_heap_serial value)
523 , bgroup (o_n_heap_prefix moduleName) (o_n_heap_serial value)
517 ]
524 ]
525+#else
526+ -- Enable FUSION_CHECK macro at the beginning of the file
527+ -- Enable one benchmark below, and run the benchmark
528+ -- Check the .dump-simpl output
529+ let value = 100000
530+ let input = source value 1
531+ let getKey buckets = (`mod` buckets)
532+ let getFold k =
533+ return $ case k of
534+ 0 -> FL.sum
535+ 1 -> FL.length
536+ _ -> FL.length
537+
538+ -- demuxToMap (getKey 64) (getFold . getKey 64) input
539+ toIntMapIO (getKey 64) input
540+ return ()
541+#endif