separate the rate benchmarks

rate benchmarks require longer time to run to provide stable results
This commit is contained in:
Harendra Kumar 2018-10-11 07:08:20 +05:30
parent bdd8a4df50
commit acbfca3502
5 changed files with 98 additions and 25 deletions

View File

@ -3,7 +3,7 @@
print_help () {
echo "Usage: $0 "
echo " [--compare] [--base commit] [--candidate commit]"
echo " [--benchmark <linear|nested|base>]"
echo " [--benchmark <linear|linear-async|linear-rate|nested|base>]"
echo " [--graphs]"
echo " [--slow]"
echo " [--no-measure]"

View File

@ -20,7 +20,7 @@ import BenchGraph
-- Command line parsing
------------------------------------------------------------------------------
data BenchType = Linear | LinearAsync | Nested | Base
data BenchType = Linear | LinearAsync | LinearRate | Nested | Base
data Options = Options
{ genGraphs :: Bool
@ -51,6 +51,7 @@ parseBench = do
case x of
Just "linear" -> setBenchType Linear
Just "linear-async" -> setBenchType LinearAsync
Just "linear-rate" -> setBenchType LinearRate
Just "nested" -> setBenchType Nested
Just "base" -> setBenchType Base
Just str -> do
@ -138,6 +139,11 @@ makeLinearAsyncGraphs cfg inputFile = do
putStrLn "Not implemented"
return ()
makeLinearRateGraphs :: Config -> String -> IO ()
makeLinearRateGraphs cfg inputFile = do
putStrLn "Not implemented"
return ()
------------------------------------------------------------------------------
-- Charts for base streams
------------------------------------------------------------------------------
@ -183,6 +189,9 @@ main = do
LinearAsync -> benchShow opts cfg makeLinearAsyncGraphs
"charts/linear-async/results.csv"
"charts/linear-async"
LinearRate -> benchShow opts cfg makeLinearRateGraphs
"charts/linear-rate/results.csv"
"charts/linear-rate"
Nested -> benchShow opts cfg makeNestedGraphs
"charts/nested/results.csv"
"charts/nested"

View File

@ -52,23 +52,6 @@ main = do
, benchSrcIO asyncly "unfoldrM maxBuffer 1 (1000 ops)"
(maxBuffer 1 . Ops.sourceUnfoldrMN 1000)
]
, bgroup "asyncly/rate"
[ -- benchIO "unfoldr" $ Ops.toNull asyncly
benchSrcIO asyncly "unfoldrM" Ops.sourceUnfoldrM
, benchSrcIO asyncly "unfoldrM/Nothing"
(rate Nothing . Ops.sourceUnfoldrM)
, benchSrcIO asyncly "unfoldrM/AvgRate/1,000,000"
(avgRate 1000000 . Ops.sourceUnfoldrM)
, benchSrcIO asyncly "unfoldrM/AvgRate/3,000,000"
(avgRate 3000000 . Ops.sourceUnfoldrM)
, benchSrcIO asyncly "unfoldrM/AvgRate/10,000,000/maxThreads1"
(maxThreads 1 . avgRate 10000000 . Ops.sourceUnfoldrM)
-- XXX arbitrarily large rate should be the same as rate Nothing
, benchSrcIO asyncly "unfoldrM/AvgRate/10,000,000"
(avgRate 10000000 . Ops.sourceUnfoldrM)
, benchSrcIO asyncly "unfoldrM/AvgRate/20,000,000"
(avgRate 20000000 . Ops.sourceUnfoldrM)
]
, bgroup "wAsyncly"
[ -- benchIO "unfoldr" $ Ops.toNull wAsyncly
benchSrcIO wAsyncly "unfoldrM" Ops.sourceUnfoldrM
@ -93,12 +76,6 @@ main = do
(maxBuffer 1 . Ops.sourceUnfoldrMN 1000)
-- , benchSrcIO aheadly "fromFoldable" Ops.sourceFromFoldable
]
, bgroup "aheadly/rate"
[
-- XXX arbitrarily large maxRate should be the same as maxRate -1
benchSrcIO aheadly "unfoldrM rate AvgRate 1000000"
(avgRate 1000000 . Ops.sourceUnfoldrM)
]
-- XXX need to use smaller streams to finish in reasonable time
, bgroup "parallely"
[ --benchIO "unfoldr" $ Ops.toNull parallely

60
benchmark/LinearRate.hs Normal file
View File

@ -0,0 +1,60 @@
-- |
-- Module : Main
-- Copyright : (c) 2018 Harendra Kumar
--
-- License : BSD3
-- Maintainer : harendra.kumar@gmail.com
-- Rate benchmarks are kept separate because they need more running time to
-- provide stable results.
-- import Data.Functor.Identity (Identity, runIdentity)
import System.Random (randomRIO)
import qualified LinearOps as Ops
import Streamly
import Gauge
-- | Takes a source, and uses it with a default drain/fold method.
{-# INLINE benchSrcIO #-}
benchSrcIO
:: (t IO Int -> SerialT IO Int)
-> String
-> (Int -> t IO Int)
-> Benchmark
benchSrcIO t name f
= bench name $ nfIO $ randomRIO (1,1) >>= Ops.toNull t . f
{-
_benchId :: NFData b => String -> (Ops.Stream m Int -> Identity b) -> Benchmark
_benchId name f = bench name $ nf (runIdentity . f) (Ops.source 10)
-}
main :: IO ()
main = do
defaultMain
-- XXX arbitrarily large rate should be the same as rate Nothing
[ bgroup "avgrate"
[ bgroup "asyncly"
[ -- benchIO "unfoldr" $ Ops.toNull asyncly
benchSrcIO asyncly "unfoldrM" Ops.sourceUnfoldrM
, benchSrcIO asyncly "unfoldrM/Nothing"
(rate Nothing . Ops.sourceUnfoldrM)
, benchSrcIO asyncly "unfoldrM/1,000,000"
(avgRate 1000000 . Ops.sourceUnfoldrM)
, benchSrcIO asyncly "unfoldrM/3,000,000"
(avgRate 3000000 . Ops.sourceUnfoldrM)
, benchSrcIO asyncly "unfoldrM/10,000,000/maxThreads1"
(maxThreads 1 . avgRate 10000000 . Ops.sourceUnfoldrM)
, benchSrcIO asyncly "unfoldrM/10,000,000"
(avgRate 10000000 . Ops.sourceUnfoldrM)
, benchSrcIO asyncly "unfoldrM/20,000,000"
(avgRate 20000000 . Ops.sourceUnfoldrM)
]
, bgroup "aheadly"
[
benchSrcIO aheadly "unfoldrM/1,000,000"
(avgRate 1000000 . Ops.sourceUnfoldrM)
]
]
]

View File

@ -351,6 +351,33 @@ benchmark linear-async
, random >= 1.0 && < 2.0
, gauge >= 0.2.3 && < 0.3
benchmark linear-rate
type: exitcode-stdio-1.0
hs-source-dirs: benchmark
main-is: LinearRate.hs
other-modules: LinearOps
default-language: Haskell2010
ghc-options: -O2 -Wall
if flag(dev)
ghc-options: -Wmissed-specialisations
-Wall-missed-specialisations
-fno-ignore-asserts
if impl(ghc >= 8.0)
ghc-options: -Wcompat
-Wunrecognised-warning-flags
-Widentities
-Wincomplete-record-updates
-Wincomplete-uni-patterns
-Wredundant-constraints
-Wnoncanonical-monad-instances
-Wnoncanonical-monadfail-instances
build-depends:
streamly
, base >= 4.8 && < 5
, deepseq >= 1.4.0 && < 1.5
, random >= 1.0 && < 2.0
, gauge >= 0.2.3 && < 0.3
benchmark nested
type: exitcode-stdio-1.0
hs-source-dirs: benchmark