on master help sign in
Move Streamly.Benchmark.CommonH to lib and change benchmark names, refactor
1ff4d3cAnurag Hooda
benchmark/Streamly/Benchmark/Data/Unfold.hs+7−9
@@ -1,7 +1,6 @@
1-- |
1-- |
2-- Module : Streamly.Benchmark.Data.Fold
2-- Module : Streamly.Benchmark.Data.Fold
3-- Copyright : (c) 2018 Composewell
3-- Copyright : (c) 2018 Composewell
4−--
5-- License : MIT
4-- License : MIT
6-- Maintainer : streamly@composewell.com
5-- Maintainer : streamly@composewell.com
7
6
@@ -22,8 +21,8 @@ module Main (main) where
22
21
23import Control.DeepSeq (NFData(..))
22import Control.DeepSeq (NFData(..))
24import Control.Exception (SomeException)
23import Control.Exception (SomeException)
25−import System.IO (Handle, hClose)
26import Streamly.Internal.Data.Unfold (Unfold)
24import Streamly.Internal.Data.Unfold (Unfold)
25+import System.IO (Handle, hClose)
27import System.Random (randomRIO)
26import System.Random (randomRIO)
28
27
29import qualified Prelude
28import qualified Prelude
@@ -39,7 +38,7 @@ import qualified Streamly.Prelude as SP
39import Gauge hiding (env)
38import Gauge hiding (env)
40import Prelude hiding (concat, take, filter, zipWith, map, mapM, takeWhile)
39import Prelude hiding (concat, take, filter, zipWith, map, mapM, takeWhile)
41import Streamly.Benchmark.Common
40import Streamly.Benchmark.Common
42−import Streamly.Benchmark.CommonH
41+import Streamly.Benchmark.Common.Handle
43
42
44#ifdef INSPECTION
43#ifdef INSPECTION
45import Test.Inspection
44import Test.Inspection
@@ -612,7 +611,7 @@ readWriteBracketUnfold inh devNull =
612
611
613o_1_space_copy_read_exceptions :: BenchEnv -> [Benchmark]
612o_1_space_copy_read_exceptions :: BenchEnv -> [Benchmark]
614o_1_space_copy_read_exceptions env =
613o_1_space_copy_read_exceptions env =
615− [ bgroup "copy/read/exceptions"
614+ [ bgroup "copy/exceptions"
616 [ mkBenchSmall "UF.onException" env $ \inh _ ->
615 [ mkBenchSmall "UF.onException" env $ \inh _ ->
617 readWriteOnExceptionUnfold inh (nullH env)
616 readWriteOnExceptionUnfold inh (nullH env)
618 , mkBenchSmall "UF.handle" env $ \inh _ ->
617 , mkBenchSmall "UF.handle" env $ \inh _ ->
@@ -636,13 +635,12 @@ o_1_space_copy_read_exceptions env =
636main :: IO ()
635main :: IO ()
637main = do
636main = do
638 (size, cfg, benches) <- parseCLIOpts defaultStreamSize
637 (size, cfg, benches) <- parseCLIOpts defaultStreamSize
639− env <- mkBenchEnv "Benchmark_FileSystem_Handle_InputFile"
638+ env <- mkHandleBenchEnv
640− size `seq` runMode (mode cfg) cfg benches (allBenchmarks size <>
639+ size `seq` runMode (mode cfg) cfg benches (allBenchmarks size env)
641− allBenchmarks' env)
642
640
643 where
641 where
644
642
645− allBenchmarks size =
643+ allBenchmarks size env =
646 [ bgroup (o_1_space_prefix moduleName)
644 [ bgroup (o_1_space_prefix moduleName)
647 $ Prelude.concat
645 $ Prelude.concat
648 [ o_1_space_transformation_input size
646 [ o_1_space_transformation_input size
@@ -651,8 +649,8 @@ main = do
651 , o_1_space_filtering size
649 , o_1_space_filtering size
652 , o_1_space_zip size
650 , o_1_space_zip size
653 , o_1_space_nested size
651 , o_1_space_nested size
652+ , o_1_space_copy_read_exceptions env
654 ]
653 ]
655 , bgroup (o_n_space_prefix moduleName)
654 , bgroup (o_n_space_prefix moduleName)
656 $ Prelude.concat [o_n_space_nested size]
655 $ Prelude.concat [o_n_space_nested size]
657 ]
656 ]
658− allBenchmarks' = o_1_space_copy_read_exceptions
benchmark/Streamly/Benchmark/FileSystem/Handle.hs+3−2
@@ -21,13 +21,14 @@
21#if __GLASGOW_HASKELL__ >= 800
21#if __GLASGOW_HASKELL__ >= 800
22#endif
22#endif
23
23
24+import Streamly.Benchmark.Common.Handle (mkHandleBenchEnv)
25+
24import qualified Handle.ReadWrite as RW
26import qualified Handle.ReadWrite as RW
25import qualified Handle.Read as RO
27import qualified Handle.Read as RO
26
28
27import Gauge hiding (env)
29import Gauge hiding (env)
28import Prelude hiding (last, length)
30import Prelude hiding (last, length)
29import Streamly.Benchmark.Common
31import Streamly.Benchmark.Common
30−import Streamly.Benchmark.CommonH
31
32
32-------------------------------------------------------------------------------
33-------------------------------------------------------------------------------
33--
34--
@@ -43,7 +44,7 @@ moduleName = "FileSystem.Handle"
43main :: IO ()
44main :: IO ()
44main = do
45main = do
45 (_, cfg, benches) <- parseCLIOpts defaultStreamSize
46 (_, cfg, benches) <- parseCLIOpts defaultStreamSize
46− env <- mkBenchEnv "Benchmark_FileSystem_Handle_InputFile"
47+ env <- mkHandleBenchEnv
47 runMode (mode cfg) cfg benches (allBenchmarks env)
48 runMode (mode cfg) cfg benches (allBenchmarks env)
48
49
49 where
50 where
benchmark/Streamly/Benchmark/FileSystem/Handle/Read.hs+1−1
@@ -47,7 +47,7 @@ import qualified Streamly.Prelude as S
47
47
48import Gauge hiding (env)
48import Gauge hiding (env)
49import Prelude hiding (last, length)
49import Prelude hiding (last, length)
50−import Streamly.Benchmark.CommonH
50+import Streamly.Benchmark.Common.Handle
51
51
52#ifdef INSPECTION
52#ifdef INSPECTION
53import Streamly.Internal.Data.Stream.StreamD.Type (Step(..), GroupState)
53import Streamly.Internal.Data.Stream.StreamD.Type (Step(..), GroupState)
benchmark/Streamly/Benchmark/FileSystem/Handle/ReadWrite.hs+1−1
@@ -34,7 +34,7 @@ import qualified Streamly.Data.Array.Storable.Foreign as A
34import qualified Streamly.Prelude as S
34import qualified Streamly.Prelude as S
35
35
36import Gauge hiding (env)
36import Gauge hiding (env)
37−import Streamly.Benchmark.CommonH
37+import Streamly.Benchmark.Common.Handle
38
38
39#ifdef INSPECTION
39#ifdef INSPECTION
40import Foreign.Storable (Storable)
40import Foreign.Storable (Storable)
benchmark/Streamly/Benchmark/Prelude/Serial.hs+7−6
@@ -11,6 +11,8 @@
11
11
12module Main (main) where
12module Main (main) where
13
13
14+import Streamly.Benchmark.Common.Handle (mkHandleBenchEnv)
15+
14import qualified Serial.Elimination as Elimination
16import qualified Serial.Elimination as Elimination
15import qualified Serial.Exceptions as Exceptions
17import qualified Serial.Exceptions as Exceptions
16import qualified Serial.Generation as Generation
18import qualified Serial.Generation as Generation
@@ -22,7 +24,6 @@ import qualified Serial.Transformation3 as Transformation3
22
24
23import Gauge hiding (env)
25import Gauge hiding (env)
24import Streamly.Benchmark.Common
26import Streamly.Benchmark.Common
25−import Streamly.Benchmark.CommonH
26
27
27moduleName :: String
28moduleName :: String
28moduleName = "Prelude.Serial"
29moduleName = "Prelude.Serial"
@@ -37,15 +38,15 @@ moduleName = "Prelude.Serial"
37main :: IO ()
38main :: IO ()
38main = do
39main = do
39 (value, cfg, benches) <- parseCLIOpts defaultStreamSize
40 (value, cfg, benches) <- parseCLIOpts defaultStreamSize
40− env <- mkBenchEnv "Benchmark_FileSystem_Handle_InputFile"
41+ env <- mkHandleBenchEnv
41− value `seq` runMode (mode cfg) cfg benches (allBenchmarks value <>
42+ value `seq` runMode (mode cfg) cfg benches (allBenchmarks value env)
42− Exceptions.allBenchmarks env <>
43− Split.allBenchmarks env)
44 where
43 where
45
44
46− allBenchmarks size = Prelude.concat
45+ allBenchmarks size env = Prelude.concat
47 [ Generation.benchmarks moduleName size
46 [ Generation.benchmarks moduleName size
48 , Elimination.benchmarks moduleName size
47 , Elimination.benchmarks moduleName size
48+ , Exceptions.benchmarks moduleName env
49+ , Split.benchmarks moduleName env
49 , Transformation1.benchmarks moduleName size
50 , Transformation1.benchmarks moduleName size
50 , Transformation2.benchmarks moduleName size
51 , Transformation2.benchmarks moduleName size
51 , Transformation3.benchmarks moduleName size
52 , Transformation3.benchmarks moduleName size
benchmark/Streamly/Benchmark/Prelude/Serial/Exceptions.hs+15−14
@@ -18,9 +18,7 @@
18{-# OPTIONS_GHC -fplugin Test.Inspection.Plugin #-}
18{-# OPTIONS_GHC -fplugin Test.Inspection.Plugin #-}
19#endif
19#endif
20
20
21−module Serial.Exceptions
21+module Serial.Exceptions (benchmarks) where
22− (allBenchmarks)
23−where
24
22
25import Control.Exception (SomeException)
23import Control.Exception (SomeException)
26import System.IO (Handle, hClose, hPutChar)
24import System.IO (Handle, hClose, hPutChar)
@@ -33,7 +31,8 @@ import qualified Streamly.Prelude as S
33
31
34import Gauge hiding (env)
32import Gauge hiding (env)
35import Prelude hiding (last, length)
33import Prelude hiding (last, length)
36−import Streamly.Benchmark.CommonH
34+import Streamly.Benchmark.Common
35+import Streamly.Benchmark.Common.Handle
37
36
38#ifdef INSPECTION
37#ifdef INSPECTION
39import Test.Inspection
38import Test.Inspection
@@ -104,7 +103,7 @@ readWriteAfter_Stream inh devNull =
104
103
105o_1_space_copy_stream_exceptions :: BenchEnv -> [Benchmark]
104o_1_space_copy_stream_exceptions :: BenchEnv -> [Benchmark]
106o_1_space_copy_stream_exceptions env =
105o_1_space_copy_stream_exceptions env =
107− [ bgroup "copy/read/exceptions"
106+ [ bgroup "exceptions"
108 [ mkBenchSmall "S.onException" env $ \inh _ ->
107 [ mkBenchSmall "S.onException" env $ \inh _ ->
109 readWriteOnExceptionStream inh (nullH env)
108 readWriteOnExceptionStream inh (nullH env)
110 , mkBenchSmall "S.handle" env $ \inh _ ->
109 , mkBenchSmall "S.handle" env $ \inh _ ->
@@ -120,7 +119,7 @@ o_1_space_copy_stream_exceptions env =
120 , mkBenchSmall "S.after_" env $ \inh _ ->
119 , mkBenchSmall "S.after_" env $ \inh _ ->
121 readWriteAfter_Stream inh (nullH env)
120 readWriteAfter_Stream inh (nullH env)
122 ]
121 ]
123− , bgroup "copy/fromToBytes/exceptions"
122+ , bgroup "exceptions/fromToBytes"
124 [ mkBenchSmall "S.bracket_" env $ \inh _ ->
123 [ mkBenchSmall "S.bracket_" env $ \inh _ ->
125 fromToBytesBracket_Stream inh (nullH env)
124 fromToBytesBracket_Stream inh (nullH env)
126 , mkBenchSmall "S.bracket" env $ \inh _ ->
125 , mkBenchSmall "S.bracket" env $ \inh _ ->
@@ -161,7 +160,7 @@ readChunksBracket inh devNull =
161
160
162o_1_space_copy_exceptions_readChunks :: BenchEnv -> [Benchmark]
161o_1_space_copy_exceptions_readChunks :: BenchEnv -> [Benchmark]
163o_1_space_copy_exceptions_readChunks env =
162o_1_space_copy_exceptions_readChunks env =
164− [ bgroup "copy/readChunks/exceptions"
163+ [ bgroup "exceptions/readChunks"
165 [ mkBench "UF.onException" env $ \inH _ ->
164 [ mkBench "UF.onException" env $ \inH _ ->
166 readChunksOnException inH (nullH env)
165 readChunksOnException inH (nullH env)
167 , mkBench "UF.bracket_" env $ \inH _ ->
166 , mkBench "UF.bracket_" env $ \inH _ ->
@@ -199,7 +198,7 @@ toChunksBracket inh devNull =
199
198
200o_1_space_copy_exceptions_toChunks :: BenchEnv -> [Benchmark]
199o_1_space_copy_exceptions_toChunks :: BenchEnv -> [Benchmark]
201o_1_space_copy_exceptions_toChunks env =
200o_1_space_copy_exceptions_toChunks env =
202− [ bgroup "copy/toChunks/exceptions"
201+ [ bgroup "exceptions/toChunks"
203 [ mkBench "S.bracket_" env $ \inH _ ->
202 [ mkBench "S.bracket_" env $ \inH _ ->
204 toChunksBracket_ inH (nullH env)
203 toChunksBracket_ inH (nullH env)
205 , mkBench "S.bracket" env $ \inH _ ->
204 , mkBench "S.bracket" env $ \inH _ ->
@@ -208,9 +207,11 @@ o_1_space_copy_exceptions_toChunks env =
208 ]
207 ]
209
208
210
209
211−allBenchmarks :: BenchEnv -> [Benchmark]
210+benchmarks :: String -> BenchEnv -> [Benchmark]
212−allBenchmarks env = Prelude.concat
211+benchmarks moduleName env =
212+ [ bgroup (o_1_space_prefix moduleName) $ concat
213− [ o_1_space_copy_exceptions_readChunks env
213+ [ o_1_space_copy_exceptions_readChunks env
214− , o_1_space_copy_exceptions_toChunks env
214+ , o_1_space_copy_exceptions_toChunks env
215− , o_1_space_copy_stream_exceptions env
215+ , o_1_space_copy_stream_exceptions env
216+ ]
216− ]
217+ ]
benchmark/Streamly/Benchmark/Prelude/Serial/Split.hs+15−14
@@ -1,8 +1,7 @@
1 -- |
1 -- |
2−-- Module : Streamly.Benchmark.Prelude.System.Split
2+-- Module : Streamly.Benchmark.Prelude.Serial.Split
3-- Copyright : (c) 2019 Composewell Technologies
3-- Copyright : (c) 2019 Composewell Technologies
4−--
5−-- License : BSD3
4+-- License : BSD-3-Clause
6-- Maintainer : streamly@composewell.com
5-- Maintainer : streamly@composewell.com
7-- Stability : experimental
6-- Stability : experimental
8-- Portability : GHC
7-- Portability : GHC
@@ -19,9 +18,7 @@
19{-# OPTIONS_GHC -fplugin Test.Inspection.Plugin #-}
18{-# OPTIONS_GHC -fplugin Test.Inspection.Plugin #-}
20#endif
19#endif
21
20
22−module Serial.Split
21+module Serial.Split (benchmarks) where
23− (allBenchmarks)
24−where
25
22
26import Data.Char (ord)
23import Data.Char (ord)
27import Data.Word (Word8)
24import Data.Word (Word8)
@@ -38,7 +35,8 @@ import qualified Streamly.Prelude as S
38
35
39import Gauge hiding (env)
36import Gauge hiding (env)
40import Prelude hiding (last, length)
37import Prelude hiding (last, length)
41−import Streamly.Benchmark.CommonH
38+import Streamly.Benchmark.Common
39+import Streamly.Benchmark.Common.Handle
42
40
43#ifdef INSPECTION
41#ifdef INSPECTION
44import Streamly.Internal.Data.Stream.StreamD.Type (Step(..))
42import Streamly.Internal.Data.Stream.StreamD.Type (Step(..))
@@ -147,7 +145,7 @@ splitOnSuffixSeq str inh =
147
145
148o_1_space_reduce_read_split :: BenchEnv -> [Benchmark]
146o_1_space_reduce_read_split :: BenchEnv -> [Benchmark]
149o_1_space_reduce_read_split env =
147o_1_space_reduce_read_split env =
150− [ bgroup "reduce/read"
148+ [ bgroup "split"
151 [ mkBench "S.parseMany (PR.sliceSepBy (== lf) FL.drain)" env
149 [ mkBench "S.parseMany (PR.sliceSepBy (== lf) FL.drain)" env
152 $ \inh _ -> parseManySepBy inh
150 $ \inh _ -> parseManySepBy inh
153 , mkBench "S.wordsBy isSpace FL.drain" env $ \inh _ ->
151 , mkBench "S.wordsBy isSpace FL.drain" env $ \inh _ ->
@@ -200,7 +198,7 @@ splitOnSeqUtf8 str inh =
200
198
201o_1_space_reduce_toChunks_split :: BenchEnv -> [Benchmark]
199o_1_space_reduce_toChunks_split :: BenchEnv -> [Benchmark]
202o_1_space_reduce_toChunks_split env =
200o_1_space_reduce_toChunks_split env =
203− [ bgroup "reduce/toChunks"
201+ [ bgroup "split/toChunks"
204 [ mkBenchSmall ("S.splitOnSeqUtf8 \"abcdefgh\" FL.drain "
202 [ mkBenchSmall ("S.splitOnSeqUtf8 \"abcdefgh\" FL.drain "
205 ++ ". US.decodeUtf8Arrays") env $ \inh _ ->
203 ++ ". US.decodeUtf8Arrays") env $ \inh _ ->
206 splitOnSeqUtf8 "abcdefgh" inh
204 splitOnSeqUtf8 "abcdefgh" inh
@@ -208,9 +206,12 @@ o_1_space_reduce_toChunks_split env =
208 env $ \inh _ -> splitOnSeqUtf8 "abcdefghijklmnopqrstuvwxyz" inh
206 env $ \inh _ -> splitOnSeqUtf8 "abcdefghijklmnopqrstuvwxyz" inh
209 ]
207 ]
210 ]
208 ]
209+
211−allBenchmarks :: BenchEnv -> [Benchmark]
210+benchmarks :: String -> BenchEnv -> [Benchmark]
212−allBenchmarks env = Prelude.concat
211+benchmarks moduleName env =
212+ [ bgroup (o_1_space_prefix moduleName) $ concat
213− [ o_1_space_reduce_read_split env
213+ [ o_1_space_reduce_read_split env
214− , o_1_space_reduce_toChunks_split env
214+ , o_1_space_reduce_toChunks_split env
215+ ]
215− ]
216+ ]
216
217
benchmark/Streamly/Benchmark/Unicode/Stream.hs+7−8
@@ -1,8 +1,7 @@
1-- |
1-- |
2-- Module : Streamly.Unicode.Stream
2-- Module : Streamly.Unicode.Stream
3-- Copyright : (c) 2019 Composewell Technologies
3-- Copyright : (c) 2019 Composewell Technologies
4−--
5−-- License : BSD3
4+-- License : BSD-3-Clause
6-- Maintainer : streamly@composewell.com
5-- Maintainer : streamly@composewell.com
7-- Stability : experimental
6-- Stability : experimental
8-- Portability : GHC
7-- Portability : GHC
@@ -19,8 +18,8 @@
19{-# OPTIONS_GHC -fplugin Test.Inspection.Plugin #-}
18{-# OPTIONS_GHC -fplugin Test.Inspection.Plugin #-}
20#endif
19#endif
21
20
22−import System.IO (Handle)
23import Prelude hiding (last, length)
21import Prelude hiding (last, length)
22+import System.IO (Handle)
24
23
25import qualified Streamly.Data.Fold as FL
24import qualified Streamly.Data.Fold as FL
26import qualified Streamly.Unicode.Stream as SS
25import qualified Streamly.Unicode.Stream as SS
@@ -34,8 +33,8 @@ import qualified Streamly.Data.Array.Storable.Foreign as A
34import qualified Streamly.Prelude as S
33import qualified Streamly.Prelude as S
35
34
36import Gauge hiding (env)
35import Gauge hiding (env)
37−import Streamly.Benchmark.CommonH
38import Streamly.Benchmark.Common
36import Streamly.Benchmark.Common
37+import Streamly.Benchmark.Common.Handle
39
38
40#ifdef INSPECTION
39#ifdef INSPECTION
41import Foreign.Storable (Storable)
40import Foreign.Storable (Storable)
@@ -65,7 +64,7 @@ inspect $ hasNoTypeClasses 'copyCodecUtf8ArraysLenient
65
64
66o_1_space_copy_chunked :: BenchEnv -> [Benchmark]
65o_1_space_copy_chunked :: BenchEnv -> [Benchmark]
67o_1_space_copy_chunked env =
66o_1_space_copy_chunked env =
68− [ bgroup "copy/toChunks"
67+ [ bgroup "decode-encode/toChunks"
69 [
68 [
70 mkBenchSmall "decodeEncodeUtf8Lenient" env $ \inH outH ->
69 mkBenchSmall "decodeEncodeUtf8Lenient" env $ \inH outH ->
71 copyCodecUtf8ArraysLenient inH outH
70 copyCodecUtf8ArraysLenient inH outH
@@ -169,7 +168,7 @@ wordsUnwordsCharArrayCopy inh outh =
169
168
170o_1_space_copy_read_group_ungroup :: BenchEnv -> [Benchmark]
169o_1_space_copy_read_group_ungroup :: BenchEnv -> [Benchmark]
171o_1_space_copy_read_group_ungroup env =
170o_1_space_copy_read_group_ungroup env =
172− [ bgroup "copy/read/group-ungroup"
171+ [ bgroup "ungroup-group"
173 [ mkBenchSmall "US.unlines . S.splitOnSuffix ([Word8])" env
172 [ mkBenchSmall "US.unlines . S.splitOnSuffix ([Word8])" env
174 $ \inh outh -> linesUnlinesCopy inh outh
173 $ \inh outh -> linesUnlinesCopy inh outh
175 , mkBenchSmall "S.interposeSuffix . S.splitOnSuffix(Array Word8)" env
174 , mkBenchSmall "S.interposeSuffix . S.splitOnSuffix(Array Word8)" env
@@ -256,7 +255,7 @@ inspect $ hasNoTypeClasses 'copyStreamUtf8
256
255
257o_1_space_copy_read :: BenchEnv -> [Benchmark]
256o_1_space_copy_read :: BenchEnv -> [Benchmark]
258o_1_space_copy_read env =
257o_1_space_copy_read env =
259− [ bgroup "copy/read"
258+ [ bgroup "decode-encode"
260 [
259 [
261 -- This needs an ascii file, as decode just errors out.
260 -- This needs an ascii file, as decode just errors out.
262 mkBench "SS.encodeLatin1' . SS.decodeLatin1" env $ \inh outh ->
261 mkBench "SS.encodeLatin1' . SS.decodeLatin1" env $ \inh outh ->
@@ -275,7 +274,7 @@ o_1_space_copy_read env =
275main :: IO ()
274main :: IO ()
276main = do
275main = do
277 (_, cfg, benches) <- parseCLIOpts defaultStreamSize
276 (_, cfg, benches) <- parseCLIOpts defaultStreamSize
278− env <- mkBenchEnv "Benchmark_FileSystem_Handle_InputFile"
277+ env <- mkHandleBenchEnv
279 runMode (mode cfg) cfg benches (allBenchmarks env)
278 runMode (mode cfg) cfg benches (allBenchmarks env)
280
279
281 where
280 where
benchmark/Streamly/Benchmark/CommonH.hs → benchmark/lib/Streamly/Benchmark/Common/Handle.hsrenamed+11−14
@@ -1,8 +1,7 @@
1-- |
1-- |
2−-- Module : Streamly.Benchmark.FileSystem.Handle
2+-- Module : Streamly.Benchmark.Common.Handle
3-- Copyright : (c) 2019 Composewell Technologies
3-- Copyright : (c) 2019 Composewell Technologies
4−--
5−-- License : BSD3
4+-- License : BSD-3-Clause
6-- Maintainer : streamly@composewell.com
5-- Maintainer : streamly@composewell.com
7-- Stability : experimental
6-- Stability : experimental
8-- Portability : GHC
7-- Portability : GHC
@@ -19,7 +18,7 @@
19{-# OPTIONS_GHC -fplugin Test.Inspection.Plugin #-}
18{-# OPTIONS_GHC -fplugin Test.Inspection.Plugin #-}
20#endif
19#endif
21
20
22−module Streamly.Benchmark.CommonH
21+module Streamly.Benchmark.Common.Handle
23 ( BenchEnv (..)
22 ( BenchEnv (..)
24 , RefHandles (..)
23 , RefHandles (..)
25 , scratchDir
24 , scratchDir
@@ -30,23 +29,22 @@ module Streamly.Benchmark.CommonH
30 , mkBenchSmall
29 , mkBenchSmall
31 , isSpace
30 , isSpace
32 , isSp
31 , isSp
33− , mkBenchEnv
32+ , mkHandleBenchEnv
34 )
33 )
35where
34where
36
35
37import Control.DeepSeq (NFData(rnf))
36import Control.DeepSeq (NFData(rnf))
38import Data.Char (ord, chr)
37import Data.Char (ord, chr)
39import Data.Word (Word8)
38import Data.Word (Word8)
39+import System.Directory (getFileSize)
40+import System.Environment (lookupEnv)
40import System.IO (openFile, IOMode(..), Handle, hClose)
41import System.IO (openFile, IOMode(..), Handle, hClose)
42+import System.Process.Typed (shell, runProcess_)
41
43
42import Data.IORef
44import Data.IORef
45+import Prelude hiding (last, length)
43import Gauge hiding (env)
46import Gauge hiding (env)
44
47
45−import System.Directory (getFileSize)
46−import System.Environment (lookupEnv)
47−-- import System.IO (openFile, IOMode(..))
48−import System.Process.Typed (shell, runProcess_)
49−import Prelude hiding (last, length)
50
48
51scratchDir :: String
49scratchDir :: String
52scratchDir = "benchmark-tmp/"
50scratchDir = "benchmark-tmp/"
@@ -166,10 +164,9 @@ smallFileSize = 10 * 1024 * 1024
166bigFileSize :: Int
164bigFileSize :: Int
167bigFileSize = 100 * 1024 * 1024
165bigFileSize = 100 * 1024 * 1024
168
166
169−-- Function to create a BenchEnv
167+mkHandleBenchEnv :: IO BenchEnv
170−mkBenchEnv :: String -> IO BenchEnv
168+mkHandleBenchEnv = do
171−mkBenchEnv envName = do
169+ r <- lookupEnv "Benchmark_FileSystem_Handle_InputFile"
172− r <- lookupEnv envName
173 (small, big) <-
170 (small, big) <-
174 case r of
171 case r of
175 Just inFileName -> return (inFileName, inFileName)
172 Just inFileName -> return (inFileName, inFileName)
benchmark/streamly-benchmarks.cabal+6−6
@@ -130,7 +130,12 @@ library
130 import: lib-options, bench-depends
130 import: lib-options, bench-depends
131 hs-source-dirs: lib
131 hs-source-dirs: lib
132 exposed-modules: Streamly.Benchmark.Common
132 exposed-modules: Streamly.Benchmark.Common
133+ , Streamly.Benchmark.Common.Handle
133 , Streamly.Benchmark.Prelude
134 , Streamly.Benchmark.Prelude
135+ build-depends:
136+ typed-process >= 0.2.3 && < 0.3
137+ , directory >= 1.2.2 && < 1.4
138+ , ghc-prim >= 0.4 && < 0.7
134
139
135-------------------------------------------------------------------------------
140-------------------------------------------------------------------------------
136-- Benchmarks
141-- Benchmarks
@@ -167,7 +172,6 @@ benchmark Prelude.Serial
167 , Serial.Nested
172 , Serial.Nested
168 , Serial.Exceptions
173 , Serial.Exceptions
169 , Serial.Split
174 , Serial.Split
170− , Streamly.Benchmark.CommonH
171 ghc-options: +RTS -M1000M -RTS
175 ghc-options: +RTS -M1000M -RTS
172 if impl(ghcjs)
176 if impl(ghcjs)
173 buildable: False
177 buildable: False
@@ -256,8 +260,7 @@ benchmark Data.Unfold
256 type: exitcode-stdio-1.0
260 type: exitcode-stdio-1.0
257 hs-source-dirs: .
261 hs-source-dirs: .
258 main-is: Streamly/Benchmark/Data/Unfold.hs
262 main-is: Streamly/Benchmark/Data/Unfold.hs
259− other-modules: Streamly.Benchmark.Data.NestedUnfoldOps
263+ other-modules: Streamly.Benchmark.Data.NestedUnfoldOps
260− , Streamly.Benchmark.CommonH
261 if impl(ghcjs)
264 if impl(ghcjs)
262 buildable: False
265 buildable: False
263 else
266 else
@@ -457,7 +460,6 @@ benchmark FileSystem.Handle
457 other-modules:
460 other-modules:
458 Handle.Read
461 Handle.Read
459 , Handle.ReadWrite
462 , Handle.ReadWrite
460− , Streamly.Benchmark.CommonH
461 build-depends:
463 build-depends:
462 typed-process >= 0.2.3 && < 0.3
464 typed-process >= 0.2.3 && < 0.3
463 , directory >= 1.2.2 && < 1.4
465 , directory >= 1.2.2 && < 1.4
@@ -471,8 +473,6 @@ benchmark Unicode.Stream
471 type: exitcode-stdio-1.0
473 type: exitcode-stdio-1.0
472 hs-source-dirs: . Streamly/Benchmark/Unicode
474 hs-source-dirs: . Streamly/Benchmark/Unicode
473 main-is: Stream.hs
475 main-is: Stream.hs
474− other-modules:
475− Streamly.Benchmark.CommonH
476 build-depends:
476 build-depends:
477 typed-process >= 0.2.3 && < 0.3
477 typed-process >= 0.2.3 && < 0.3
478 , directory >= 1.2.2 && < 1.4
478 , directory >= 1.2.2 && < 1.4
streamly.cabal+1−1
@@ -109,7 +109,6 @@ extra-source-files:
109 bench.sh
109 bench.sh
110 benchmark/*.hs
110 benchmark/*.hs
111 benchmark/README.md
111 benchmark/README.md
112− benchmark/Streamly/Benchmark/CommonH.hs
113 benchmark/Streamly/Benchmark/Data/*.hs
112 benchmark/Streamly/Benchmark/Data/*.hs
114 benchmark/Streamly/Benchmark/Data/Parser/*.hs
113 benchmark/Streamly/Benchmark/Data/Parser/*.hs
115 benchmark/Streamly/Benchmark/Data/Stream/*.hs
114 benchmark/Streamly/Benchmark/Data/Stream/*.hs
@@ -119,6 +118,7 @@ extra-source-files:
119 benchmark/Streamly/Benchmark/Prelude/Serial/*.hs
118 benchmark/Streamly/Benchmark/Prelude/Serial/*.hs
120 benchmark/Streamly/Benchmark/Unicode/*.hs
119 benchmark/Streamly/Benchmark/Unicode/*.hs
121 benchmark/lib/Streamly/Benchmark/*.hs
120 benchmark/lib/Streamly/Benchmark/*.hs
121+ benchmark/lib/Streamly/Benchmark/Common/*.hs
122 benchmark/streamly-benchmarks.cabal
122 benchmark/streamly-benchmarks.cabal
123 bin/bench-exec-one.sh
123 bin/bench-exec-one.sh
124 bin/mk-hscope.sh
124 bin/mk-hscope.sh