Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3dfc26b
commit f99a20e
Showing
9 changed files
with
291 additions
and
441 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- | | ||
|
||
module Main where | ||
|
||
import Prelude | ||
import Data.Bool | ||
import Data.Foldable | ||
import Box | ||
|
||
data Teletype m a where | ||
ReadTTY :: Teletype m String | ||
WriteTTY :: String -> Teletype m () | ||
|
||
echo :: (Monad m, Eq a, Monoid a) => Box m a a -> m () | ||
echo = fuse (\x -> bool (pure (Just x)) (pure Nothing) (x == mempty)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{-# LANGUAGE BangPatterns #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE StrictData #-} | ||
{-# OPTIONS_GHC -Wall #-} | ||
{-# OPTIONS_GHC -Wno-unused-do-bind #-} | ||
|
||
import Control.Applicative | ||
import Control.Monad | ||
import Data.List (intercalate) | ||
import qualified Data.Map.Strict as Map | ||
import Data.Semigroup | ||
import Options.Applicative | ||
import Perf | ||
import Prelude | ||
import Box | ||
|
||
toListMTest :: Int -> IO [Int] | ||
toListMTest n = toListM <$|> qListWith Unbounded [1..n] | ||
|
||
pushListTest :: Int -> IO [Int] | ||
pushListTest n = pushList <$|> (qListWith Unbounded [1..n]) | ||
|
||
data TestType = TestToListM | TestQList | TestDefault deriving (Eq, Show) | ||
|
||
parseTestType :: Parser TestType | ||
parseTestType = | ||
flag' TestToListM (long "toListM" <> help "test toListM speed") | ||
<|> flag' TestQList (long "qList" <> help "test qList speed") | ||
<|> pure TestDefault | ||
|
||
data Options = Options | ||
{ optionN :: Int, | ||
optionL :: Int, | ||
optionStatDType :: StatDType, | ||
optionTestType :: TestType, | ||
optionMeasureType :: MeasureType, | ||
optionGolden :: Golden, | ||
optionReportConfig :: ReportConfig, | ||
optionRawStats :: Bool | ||
} | ||
deriving (Eq, Show) | ||
|
||
options :: Parser Options | ||
options = | ||
Options | ||
<$> option auto (value 1000 <> long "runs" <> short 'n' <> help "number of tests to perform") | ||
<*> option auto (value 1000 <> long "length" <> short 'l' <> help "number of emits") | ||
<*> parseStatD | ||
<*> parseTestType | ||
<*> parseMeasure | ||
<*> parseGolden "golden" | ||
<*> parseReportConfig defaultReportConfig | ||
<*> switch (long "raw" <> short 'w' <> help "write raw statistics to file") | ||
|
||
opts :: ParserInfo Options | ||
opts = | ||
info | ||
(options <**> helper) | ||
(fullDesc <> progDesc "box benchmarking" <> header "speed performance") | ||
|
||
main :: IO () | ||
main = do | ||
o <- execParser opts | ||
let !n = optionN o | ||
let !l = optionL o | ||
let t = optionTestType o | ||
let mt = optionMeasureType o | ||
let gold = goldenFromOptions [show mt, show n, show l] (optionGolden o) | ||
let w = optionRawStats o | ||
let raw = "other/" <> intercalate "-" [show mt, show t, show n] <> ".map" | ||
let cfg = optionReportConfig o | ||
|
||
case t of | ||
TestQList -> do | ||
error "nyi" | ||
TestToListM -> do | ||
error "nyi" | ||
TestDefault -> do | ||
m <- fmap (fmap (measureFinalStat mt)) $ | ||
execPerfT (fmap (fmap average) $ measureDs mt n) $ do | ||
_ <- fam "sum fold" (pure $ sum [1..l]) | ||
_ <- fam "toListM" (toListMTest l) | ||
_ <- fam "pushList" (pushListTest l) | ||
|
||
pure () | ||
when w (writeFile raw (show m)) | ||
report cfg gold (measureLabels mt) (Map.mapKeys (: []) (fmap (: []) m)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
packages: | ||
box.cabal | ||
../perf/perf.cabal | ||
|
||
allow-newer: numhask-space:semigroupoids, | ||
tdigest:semigroupoids |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fromList [(["pushList","time"],1700193.684),(["sum fold","time"],1851.174),(["toListM","time"],1137498.997)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fromList [(["pushList","time"],1639947.761),(["sum fold","time"],1818.752),(["toListM","time"],1123639.039)] |
Oops, something went wrong.