on master help sign in
Fix imports, comments and change RTS flags in streamly-benchmarks.cabal
425df88Anurag Hooda
benchmark/Streamly/Benchmark/Data/Unfold.hs+17−20
@@ -21,28 +21,29 @@
21module Main (main) where
21module Main (main) where
22
22
23import Control.DeepSeq (NFData(..))
23import Control.DeepSeq (NFData(..))
24−import System.Random (randomRIO)
24+import Control.Exception (SomeException)
25+import System.IO (Handle, hClose)
25import Streamly.Internal.Data.Unfold (Unfold)
26import Streamly.Internal.Data.Unfold (Unfold)
27+import System.Random (randomRIO)
26
28
27import qualified Prelude
29import qualified Prelude
30+import qualified Streamly.Benchmark.Data.NestedUnfoldOps as Nested
31+import qualified Streamly.FileSystem.Handle as FH
28import qualified Streamly.Internal.Data.Fold as FL
32import qualified Streamly.Internal.Data.Fold as FL
29import qualified Streamly.Internal.Data.Unfold as UF
33import qualified Streamly.Internal.Data.Unfold as UF
30import qualified Streamly.Internal.Data.Stream.IsStream as S
34import qualified Streamly.Internal.Data.Stream.IsStream as S
31import qualified Streamly.Internal.Data.Stream.StreamD as D
35import qualified Streamly.Internal.Data.Stream.StreamD as D
32import qualified Streamly.Internal.Data.Stream.StreamK as K
36import qualified Streamly.Internal.Data.Stream.StreamK as K
33−import qualified Streamly.Benchmark.Data.NestedUnfoldOps as Nested
34−
35−-- For Unfold Exception Benchmarks
36−import qualified Streamly.FileSystem.Handle as FH
37−import qualified Streamly.Internal.Data.Unfold as IUF
38import qualified Streamly.Prelude as SP
37import qualified Streamly.Prelude as SP
39−import Streamly.Benchmark.CommonH
40−import System.IO (Handle, hClose)
41−import Control.Exception (SomeException)
42
38
43−import Streamly.Benchmark.Common
44import Gauge hiding (env)
39import Gauge hiding (env)
45import Prelude hiding (concat, take, filter, zipWith, map, mapM, takeWhile)
40import Prelude hiding (concat, take, filter, zipWith, map, mapM, takeWhile)
41+import Streamly.Benchmark.Common
42+import Streamly.Benchmark.CommonH
43+
44+#ifdef INSPECTION
45+import Test.Inspection
46+#endif
46
47
47{-# INLINE benchIO #-}
48{-# INLINE benchIO #-}
48benchIO :: (NFData b) => String -> (Int -> IO b) -> Benchmark
49benchIO :: (NFData b) => String -> (Int -> IO b) -> Benchmark
@@ -428,7 +429,6 @@ _apDiscardFst = undefined
428_apDiscardSnd :: Int -> Int -> m ()
429_apDiscardSnd :: Int -> Int -> m ()
429_apDiscardSnd = undefined
430_apDiscardSnd = undefined
430
431
431−
432-------------------------------------------------------------------------------
432-------------------------------------------------------------------------------
433-- Benchmarks
433-- Benchmarks
434-------------------------------------------------------------------------------
434-------------------------------------------------------------------------------
@@ -558,7 +558,7 @@ o_n_space_nested size =
558-- | Send the file contents to /dev/null with exception handling
558-- | Send the file contents to /dev/null with exception handling
559readWriteOnExceptionUnfold :: Handle -> Handle -> IO ()
559readWriteOnExceptionUnfold :: Handle -> Handle -> IO ()
560readWriteOnExceptionUnfold inh devNull =
560readWriteOnExceptionUnfold inh devNull =
561− let readEx = IUF.onException (\_ -> hClose inh) FH.read
561+ let readEx = UF.onException (\_ -> hClose inh) FH.read
562 in SP.fold (FH.write devNull) $ SP.unfold readEx inh
562 in SP.fold (FH.write devNull) $ SP.unfold readEx inh
563
563
564#ifdef INSPECTION
564#ifdef INSPECTION
@@ -570,7 +570,7 @@ inspect $ hasNoTypeClasses 'readWriteOnExceptionUnfold
570readWriteHandleExceptionUnfold :: Handle -> Handle -> IO ()
570readWriteHandleExceptionUnfold :: Handle -> Handle -> IO ()
571readWriteHandleExceptionUnfold inh devNull =
571readWriteHandleExceptionUnfold inh devNull =
572 let handler (_e :: SomeException) = hClose inh >> return 10
572 let handler (_e :: SomeException) = hClose inh >> return 10
573− readEx = IUF.handle (IUF.singletonM handler) FH.read
573+ readEx = UF.handle (UF.singletonM handler) FH.read
574 in SP.fold (FH.write devNull) $ SP.unfold readEx inh
574 in SP.fold (FH.write devNull) $ SP.unfold readEx inh
575
575
576#ifdef INSPECTION
576#ifdef INSPECTION
@@ -581,7 +581,7 @@ inspect $ hasNoTypeClasses 'readWriteHandleExceptionUnfold
581-- | Send the file contents to /dev/null with exception handling
581-- | Send the file contents to /dev/null with exception handling
582readWriteFinally_Unfold :: Handle -> Handle -> IO ()
582readWriteFinally_Unfold :: Handle -> Handle -> IO ()
583readWriteFinally_Unfold inh devNull =
583readWriteFinally_Unfold inh devNull =
584− let readEx = IUF.finally_ (\_ -> hClose inh) FH.read
584+ let readEx = UF.finally_ (\_ -> hClose inh) FH.read
585 in SP.fold (FH.write devNull) $ SP.unfold readEx inh
585 in SP.fold (FH.write devNull) $ SP.unfold readEx inh
586
586
587#ifdef INSPECTION
587#ifdef INSPECTION
@@ -591,13 +591,13 @@ inspect $ hasNoTypeClasses 'readWriteFinally_Unfold
591
591
592readWriteFinallyUnfold :: Handle -> Handle -> IO ()
592readWriteFinallyUnfold :: Handle -> Handle -> IO ()
593readWriteFinallyUnfold inh devNull =
593readWriteFinallyUnfold inh devNull =
594− let readEx = IUF.finally (\_ -> hClose inh) FH.read
594+ let readEx = UF.finally (\_ -> hClose inh) FH.read
595 in SP.fold (FH.write devNull) $ SP.unfold readEx inh
595 in SP.fold (FH.write devNull) $ SP.unfold readEx inh
596
596
597-- | Send the file contents to /dev/null with exception handling
597-- | Send the file contents to /dev/null with exception handling
598readWriteBracket_Unfold :: Handle -> Handle -> IO ()
598readWriteBracket_Unfold :: Handle -> Handle -> IO ()
599readWriteBracket_Unfold inh devNull =
599readWriteBracket_Unfold inh devNull =
600− let readEx = IUF.bracket_ return (\_ -> hClose inh) FH.read
600+ let readEx = UF.bracket_ return (\_ -> hClose inh) FH.read
601 in SP.fold (FH.write devNull) $ SP.unfold readEx inh
601 in SP.fold (FH.write devNull) $ SP.unfold readEx inh
602
602
603#ifdef INSPECTION
603#ifdef INSPECTION
@@ -607,7 +607,7 @@ inspect $ hasNoTypeClasses 'readWriteBracket_Unfold
607
607
608readWriteBracketUnfold :: Handle -> Handle -> IO ()
608readWriteBracketUnfold :: Handle -> Handle -> IO ()
609readWriteBracketUnfold inh devNull =
609readWriteBracketUnfold inh devNull =
610− let readEx = IUF.bracket return (\_ -> hClose inh) FH.read
610+ let readEx = UF.bracket return (\_ -> hClose inh) FH.read
611 in SP.fold (FH.write devNull) $ S.unfold readEx inh
611 in SP.fold (FH.write devNull) $ S.unfold readEx inh
612
612
613o_1_space_copy_read_exceptions :: BenchEnv -> [Benchmark]
613o_1_space_copy_read_exceptions :: BenchEnv -> [Benchmark]
@@ -651,9 +651,6 @@ main = do
651 , o_1_space_filtering size
651 , o_1_space_filtering size
652 , o_1_space_zip size
652 , o_1_space_zip size
653 , o_1_space_nested size
653 , o_1_space_nested size
654− -- I have to pass BenchEnv instead of size here
655− -- DONE
656− -- , o_1_space_copy_read_exceptions env
657 ]
654 ]
658 , bgroup (o_n_space_prefix moduleName)
655 , bgroup (o_n_space_prefix moduleName)
659 $ Prelude.concat [o_n_space_nested size]
656 $ Prelude.concat [o_n_space_nested size]
benchmark/Streamly/Benchmark/FileSystem/Handle.hs+2−3
@@ -1,8 +1,7 @@
1-- |
1-- |
2-- Module : Streamly.Benchmark.FileSystem.Handle
2-- Module : Streamly.Benchmark.FileSystem.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
@@ -21,12 +20,12 @@
21
20
22#if __GLASGOW_HASKELL__ >= 800
21#if __GLASGOW_HASKELL__ >= 800
23#endif
22#endif
24−import Prelude hiding (last, length)
25
23
26import qualified Handle.ReadWrite as RW
24import qualified Handle.ReadWrite as RW
27import qualified Handle.Read as RO
25import qualified Handle.Read as RO
28
26
29import Gauge hiding (env)
27import Gauge hiding (env)
28+import Prelude hiding (last, length)
30import Streamly.Benchmark.Common
29import Streamly.Benchmark.Common
31import Streamly.Benchmark.CommonH
30import Streamly.Benchmark.CommonH
32
31
benchmark/Streamly/Benchmark/FileSystem/Handle/Read.hs+2−5
@@ -1,8 +1,7 @@
1-- |
1-- |
2-- Module : Streamly.Benchmark.FileSystem.Handle
2-- Module : Streamly.Benchmark.FileSystem.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
@@ -32,12 +31,10 @@ import GHC.Magic (noinline)
32#define noinline
31#define noinline
33#endif
32#endif
34import System.IO (Handle)
33import System.IO (Handle)
35−import Prelude hiding (last, length)
36
34
37import qualified Streamly.Data.Fold as FL
35import qualified Streamly.Data.Fold as FL
38import qualified Streamly.Unicode.Stream as SS
36import qualified Streamly.Unicode.Stream as SS
39import qualified Streamly.FileSystem.Handle as FH
37import qualified Streamly.FileSystem.Handle as FH
40−-- import qualified Streamly.Internal.Data.Fold as IFL
41import qualified Streamly.Internal.Data.Parser as PR
38import qualified Streamly.Internal.Data.Parser as PR
42import qualified Streamly.Internal.Data.Stream.StreamD as D
39import qualified Streamly.Internal.Data.Stream.StreamD as D
43import qualified Streamly.Internal.Unicode.Stream as IUS
40import qualified Streamly.Internal.Unicode.Stream as IUS
@@ -49,7 +46,7 @@ import qualified Streamly.Internal.Data.Stream.IsStream as IP
49import qualified Streamly.Prelude as S
46import qualified Streamly.Prelude as S
50
47
51import Gauge hiding (env)
48import Gauge hiding (env)
52−-- import Handle.Common
49+import Prelude hiding (last, length)
53import Streamly.Benchmark.CommonH
50import Streamly.Benchmark.CommonH
54
51
55#ifdef INSPECTION
52#ifdef INSPECTION
benchmark/Streamly/Benchmark/FileSystem/Handle/ReadWrite.hs+1−3
@@ -1,8 +1,7 @@
1-- |
1-- |
2-- Module : Streamly.Benchmark.FileSystem.Handle
2-- Module : Streamly.Benchmark.FileSystem.Handle
3-- Copyright : (c) 2019 Composewell Technologies
3-- Copyright : (c) 2019 Composewell Technologies
4−--
5−-- License : BSD3
4+-- License : BSD3-3-Clause
6-- Maintainer : streamly@composewell.com
5-- Maintainer : streamly@composewell.com
7-- Stability : experimental
6-- Stability : experimental
8-- Portability : GHC
7-- Portability : GHC
@@ -35,7 +34,6 @@ import qualified Streamly.Data.Array.Storable.Foreign as A
35import qualified Streamly.Prelude as S
34import qualified Streamly.Prelude as S
36
35
37import Gauge hiding (env)
36import Gauge hiding (env)
38−-- import Handle.Common
39import Streamly.Benchmark.CommonH
37import Streamly.Benchmark.CommonH
40
38
41#ifdef INSPECTION
39#ifdef INSPECTION
benchmark/Streamly/Benchmark/Prelude/Serial.hs+4−5
@@ -11,18 +11,17 @@
11
11
12module Main (main) where
12module Main (main) where
13
13
14−import qualified Serial.Generation as Generation
15import qualified Serial.Elimination as Elimination
14import qualified Serial.Elimination as Elimination
15+import qualified Serial.Exceptions as Exceptions
16+import qualified Serial.Generation as Generation
17+import qualified Serial.Nested as Nested
18+import qualified Serial.Split as Split
16import qualified Serial.Transformation1 as Transformation1
19import qualified Serial.Transformation1 as Transformation1
17import qualified Serial.Transformation2 as Transformation2
20import qualified Serial.Transformation2 as Transformation2
18import qualified Serial.Transformation3 as Transformation3
21import qualified Serial.Transformation3 as Transformation3
19−import qualified Serial.Nested as Nested
20−import qualified Serial.Exceptions as Exceptions
21−import qualified Serial.Split as Split
22
22
23import Gauge hiding (env)
23import Gauge hiding (env)
24import Streamly.Benchmark.Common
24import Streamly.Benchmark.Common
25−
26import Streamly.Benchmark.CommonH
25import Streamly.Benchmark.CommonH
27
26
28moduleName :: String
27moduleName :: String
benchmark/Streamly/Benchmark/Prelude/Serial/Exceptions.hs+3−13
@@ -1,8 +1,7 @@
1-- |
1-- |
2-- Module : Streamly.Benchmark.Prelude.Serial.Exceptions
2-- Module : Streamly.Benchmark.Prelude.Serial.Exceptions
3−-- Copyright : (c) 2020 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
@@ -25,7 +24,6 @@ where
25
24
26import Control.Exception (SomeException)
25import Control.Exception (SomeException)
27import System.IO (Handle, hClose, hPutChar)
26import System.IO (Handle, hClose, hPutChar)
28−import Prelude hiding (last, length)
29
27
30import qualified Streamly.FileSystem.Handle as FH
28import qualified Streamly.FileSystem.Handle as FH
31import qualified Streamly.Internal.Data.Unfold as IUF
29import qualified Streamly.Internal.Data.Unfold as IUF
@@ -34,18 +32,10 @@ import qualified Streamly.Internal.Data.Stream.IsStream as IP
34import qualified Streamly.Prelude as S
32import qualified Streamly.Prelude as S
35
33
36import Gauge hiding (env)
34import Gauge hiding (env)
37−-- import Handle.Common
35+import Prelude hiding (last, length)
38import Streamly.Benchmark.CommonH
36import Streamly.Benchmark.CommonH
39
37
40#ifdef INSPECTION
38#ifdef INSPECTION
41−import Foreign.Storable (Storable)
42−import Streamly.Internal.Data.Stream.StreamD.Type (Step(..))
43−
44−import qualified Streamly.Internal.Data.Stream.StreamD.Type as D
45−import qualified Streamly.Internal.Data.Tuple.Strict as Strict
46−import qualified Streamly.Internal.Data.Array.Storable.Foreign as A
47−import qualified Streamly.Internal.Data.Array.Storable.Foreign.Types as AT
48−
49import Test.Inspection
39import Test.Inspection
50#endif
40#endif
51
41
benchmark/Streamly/Benchmark/Prelude/Serial/Split.hs+1−1
@@ -26,7 +26,6 @@ where
26import Data.Char (ord)
26import Data.Char (ord)
27import Data.Word (Word8)
27import Data.Word (Word8)
28import System.IO (Handle)
28import System.IO (Handle)
29−import Prelude hiding (last, length)
30
29
31import qualified Streamly.Data.Fold as FL
30import qualified Streamly.Data.Fold as FL
32import qualified Streamly.FileSystem.Handle as FH
31import qualified Streamly.FileSystem.Handle as FH
@@ -38,6 +37,7 @@ import qualified Streamly.Internal.Data.Stream.IsStream as IP
38import qualified Streamly.Prelude as S
37import qualified Streamly.Prelude as S
39
38
40import Gauge hiding (env)
39import Gauge hiding (env)
40+import Prelude hiding (last, length)
41import Streamly.Benchmark.CommonH
41import Streamly.Benchmark.CommonH
42
42
43#ifdef INSPECTION
43#ifdef INSPECTION
benchmark/Streamly/Benchmark/Unicode/Stream.hs+1−17
@@ -190,19 +190,6 @@ o_1_space_copy_read_group_ungroup env =
190-- copy unfold
190-- copy unfold
191-------------------------------------------------------------------------------
191-------------------------------------------------------------------------------
192
192
193−-- -- | Copy file
194−-- copyStream :: Handle -> Handle -> IO ()
195−-- copyStream inh outh = S.fold (FH.write outh) (S.unfold FH.read inh)
196−
197−-- #ifdef INSPECTION
198−-- inspect $ hasNoTypeClasses 'copyStream
199−-- inspect $ 'copyStream `hasNoType` ''Step -- S.unfold
200−-- inspect $ 'copyStream `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
201−-- inspect $ 'copyStream `hasNoType` ''A.ReadUState -- FH.read/A.read
202−-- inspect $ 'copyStream `hasNoType` ''AT.ArrayUnsafe -- FH.write/writeNUnsafe
203−-- inspect $ 'copyStream `hasNoType` ''Strict.Tuple3' -- FH.write/lchunksOf
204−-- #endif
205−
206-- | Copy file (encodeLatin1')
193-- | Copy file (encodeLatin1')
207copyStreamLatin1' :: Handle -> Handle -> IO ()
194copyStreamLatin1' :: Handle -> Handle -> IO ()
208copyStreamLatin1' inh outh =
195copyStreamLatin1' inh outh =
@@ -270,10 +257,7 @@ inspect $ hasNoTypeClasses 'copyStreamUtf8
270o_1_space_copy_read :: BenchEnv -> [Benchmark]
257o_1_space_copy_read :: BenchEnv -> [Benchmark]
271o_1_space_copy_read env =
258o_1_space_copy_read env =
272 [ bgroup "copy/read"
259 [ bgroup "copy/read"
273− [-- mkBench "rawToNull" env $ \inh _ ->
260+ [
274− -- copyStream inh (nullH env)
275− -- , mkBench "rawToFile" env $ \inh outh ->
276− -- copyStream inh outh
277 -- This needs an ascii file, as decode just errors out.
261 -- This needs an ascii file, as decode just errors out.
278 mkBench "SS.encodeLatin1' . SS.decodeLatin1" env $ \inh outh ->
262 mkBench "SS.encodeLatin1' . SS.decodeLatin1" env $ \inh outh ->
279 copyStreamLatin1' inh outh
263 copyStreamLatin1' inh outh
benchmark/streamly-benchmarks.cabal+5−6
@@ -167,7 +167,8 @@ benchmark Prelude.Serial
167 , Serial.Nested
167 , Serial.Nested
168 , Serial.Exceptions
168 , Serial.Exceptions
169 , Serial.Split
169 , Serial.Split
170− ,Streamly.Benchmark.CommonH
170+ , Streamly.Benchmark.CommonH
171+ ghc-options: +RTS -M1000M -RTS
171 if impl(ghcjs)
172 if impl(ghcjs)
172 buildable: False
173 buildable: False
173 else
174 else
@@ -176,6 +177,7 @@ benchmark Prelude.Serial
176 typed-process >= 0.2.3 && < 0.3
177 typed-process >= 0.2.3 && < 0.3
177 , directory >= 1.2.2 && < 1.4
178 , directory >= 1.2.2 && < 1.4
178 , ghc-prim >= 0.4 && < 0.7
179 , ghc-prim >= 0.4 && < 0.7
180+ , inspection-testing >= 0.4 && < 0.5
179
181
180benchmark Prelude.WSerial
182benchmark Prelude.WSerial
181 import: bench-options
183 import: bench-options
@@ -254,8 +256,8 @@ benchmark Data.Unfold
254 type: exitcode-stdio-1.0
256 type: exitcode-stdio-1.0
255 hs-source-dirs: .
257 hs-source-dirs: .
256 main-is: Streamly/Benchmark/Data/Unfold.hs
258 main-is: Streamly/Benchmark/Data/Unfold.hs
257− other-modules: Streamly.Benchmark.Data.NestedUnfoldOps
259+ other-modules: Streamly.Benchmark.Data.NestedUnfoldOps
258− ,Streamly.Benchmark.CommonH
260+ , Streamly.Benchmark.CommonH
259 if impl(ghcjs)
261 if impl(ghcjs)
260 buildable: False
262 buildable: False
261 else
263 else
@@ -382,7 +384,6 @@ benchmark Prelude.Adaptive
382 type: exitcode-stdio-1.0
384 type: exitcode-stdio-1.0
383 hs-source-dirs: Streamly/Benchmark/Prelude
385 hs-source-dirs: Streamly/Benchmark/Prelude
384 main-is: Adaptive.hs
386 main-is: Adaptive.hs
385− ghc-options: +RTS -M3000M -RTS
386 if impl(ghcjs)
387 if impl(ghcjs)
387 buildable: False
388 buildable: False
388 else
389 else
@@ -456,7 +457,6 @@ benchmark FileSystem.Handle
456 other-modules:
457 other-modules:
457 Handle.Read
458 Handle.Read
458 , Handle.ReadWrite
459 , Handle.ReadWrite
459− -- , Handle.Common
460 , Streamly.Benchmark.CommonH
460 , Streamly.Benchmark.CommonH
461 build-depends:
461 build-depends:
462 typed-process >= 0.2.3 && < 0.3
462 typed-process >= 0.2.3 && < 0.3
@@ -469,7 +469,6 @@ benchmark FileSystem.Handle
469benchmark Unicode.Stream
469benchmark Unicode.Stream
470 import: bench-options
470 import: bench-options
471 type: exitcode-stdio-1.0
471 type: exitcode-stdio-1.0
472− ghc-options: +RTS -M3000M -RTS
473 hs-source-dirs: . Streamly/Benchmark/Unicode
472 hs-source-dirs: . Streamly/Benchmark/Unicode
474 main-is: Stream.hs
473 main-is: Stream.hs
475 other-modules:
474 other-modules: