2-- Module : Streamly.Benchmark.FileSystem.Handle
3-- Copyright : (c) 2019 Composewell Technologies
6-- Maintainer : streamly@composewell.com
7-- Stability : experimental
11{-# LANGUAGE ScopedTypeVariables #-}
13#ifdef __HADDOCK_VERSION__
18{-# LANGUAGE TemplateHaskell #-}
19{-# OPTIONS_GHC -fplugin Test.Inspection.Plugin #-}
22#if __GLASGOW_HASKELL__ >= 800
23import System.Directory (getFileSize)
25import System.Environment (lookupEnv)
26import System.IO (openFile, IOMode(..))
27import System.Process.Typed (shell, runProcess_)
28import Prelude hiding (last, length)
30import qualified Handle.ReadWrite as RW
31import qualified Handle.Read as RO
34import Gauge hiding (env)
35import Streamly.Benchmark.Common
38-------------------------------------------------------------------------------
40-------------------------------------------------------------------------------
43moduleName = "FileSystem.Handle"
45-------------------------------------------------------------------------------
47-------------------------------------------------------------------------------
50smallFileSize = 10 * 1024 * 1024
53bigFileSize = 100 * 1024 * 1024
55-------------------------------------------------------------------------------
57-------------------------------------------------------------------------------
61 (_, cfg, benches) <- parseCLIOpts defaultStreamSize
62 r <- lookupEnv "Benchmark_FileSystem_Handle_InputFile"
65 Just inFileName -> return (inFileName, inFileName)
67 -- XXX will this work on windows/msys?
69 "mkdir -p " ++ scratchDir
70 ++ "; test -e " ++ infile
71 ++ " || { echo \"creating input file " ++ infile
72 ++ "\" && head -c " ++ show size
73 ++ " </dev/urandom >" ++ infile
75 runProcess_ (shell (cmd inFileSmall smallFileSize))
76 runProcess_ (shell (cmd inFileBig bigFileSize))
77 return (inFileSmall, inFileBig)
79 putStrLn $ "Using small input file: " ++ small
80 smallHandle <- openFile small ReadMode
82 putStrLn $ "Using big input file: " ++ big
83 bigHandle <- openFile big ReadMode
85 putStrLn $ "Using output file: " ++ outfile
86 outHandle <- openFile outfile WriteMode
87 devNull <- openFile "/dev/null" WriteMode
89 ssize <- fromIntegral <$> getFileSize small
90 bsize <- fromIntegral <$> getFileSize big
92 ref <- newIORef $ RefHandles
93 { smallInH = smallHandle
103 , smallInFile = small
107 runMode (mode cfg) cfg benches (allBenchmarks env)
112 [ bgroup (o_1_space_prefix moduleName) $ Prelude.concat
113 [ RO.allBenchmarks env
114 , RW.allBenchmarks env
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list