mealy 0.5.1.0 → 0.5.1.1
raw patch · 2 files changed
+3/−128 lines, 2 filesdep −mealydep −optparse-applicativedep −perfdep ~basedep ~harpiedep ~harpie-numhask
Dependencies removed: mealy, optparse-applicative, perf
Dependency ranges changed: base, harpie, harpie-numhask
Files
- mealy.cabal +3/−27
- test/mealy-perf.hs +0/−101
mealy.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: mealy-version: 0.5.1.0+version: 0.5.1.1 license: BSD-3-Clause license-file: LICENSE copyright: Tony Day (c) 2013@@ -53,8 +53,8 @@ adjunctions >=4.0 && <4.5, base >=4.14 && <5, containers >=0.6 && <0.9,- harpie >=0.1 && <0.2,- harpie-numhask >=0.1 && <0.2,+ harpie >=0.1 && <0.3,+ harpie-numhask >=0.1 && <0.3, mwc-probability >=2.3.1 && <2.4, numhask >=0.11 && <0.14, primitive >=0.7.2 && <0.10,@@ -69,27 +69,3 @@ Data.Mealy.Quantiles Data.Mealy.Simulate -common ghc-options-exe-stanza- ghc-options:- -fforce-recomp- -funbox-strict-fields- -rtsopts- -threaded- -with-rtsopts=-N--executable mealy-perf- import: ghc-options-exe-stanza- import: ghc-options-stanza- default-language: GHC2024- main-is: mealy-perf.hs- hs-source-dirs: test- build-depends:- base >=4.7 && <5,- containers >=0.6 && <0.9,- mealy,- optparse-applicative >=0.17 && <0.20,- perf >=0.14 && <0.15,- tdigest >=0.2.1 && <0.4,- text >=1.2 && <2.2,-- ghc-options: -O2
− test/mealy-perf.hs
@@ -1,101 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}---- | performance measurement-module Main where--import Control.Category (id)-import Control.Monad-import Data.List (intercalate)-import Data.Map.Strict (Map)-import Data.Maybe-import Data.Mealy-import Data.Mealy.Quantiles-import Data.Mealy.Simulate-import Data.TDigest hiding (median)-import Data.Text (Text)-import Options.Applicative-import Perf-import Prelude hiding (id)--data Run = RunStats | RunQuantiles [Double] deriving (Eq, Show)--data AppConfig = AppConfig- { appReportOptions :: ReportOptions,- appRun :: Run- }- deriving (Eq, Show)--parseRun :: Parser Run-parseRun =- flag' RunStats (long "stats" <> help "run stats test")- <|> flag' (RunQuantiles [0.1, 0.5, 0.9]) (long "quantiles" <> help "run quantiles test")- <|> pure RunStats--parseAppConfig :: Parser AppConfig-parseAppConfig =- AppConfig- <$> parseReportOptions defaultReportOptions- <*> parseRun--appInfo :: ParserInfo AppConfig-appInfo =- info- (parseAppConfig <**> helper)- (fullDesc <> progDesc "mealy performance measurement")--main :: IO ()-main = do- o <- execParser appInfo- let repOptions = appReportOptions o- let n = reportN repOptions- let s = reportStatDType repOptions- let mt = reportMeasureType repOptions- let run = appRun o- let l = reportLength repOptions- gen <- create- _ <- warmup 100- case run of- RunStats -> do- xs <- rvs gen l- reportMain ExampleSum repOptions (intercalate "-" [show run, show n, show l, show s, show mt]) (void . stats xs)- RunQuantiles qs -> do- xs <- rvs gen l- reportMain ExampleSum repOptions (intercalate "-" [show run, show n, show l, show s, show mt]) (void . perfQuantiles xs qs)--reportRaw :: ReportOptions -> PerfT IO [[Double]] a -> IO (a, Map Text [[Double]])-reportRaw o t = do- let !n = reportN o- let c = reportClock o- let mt = reportMeasureType o- runPerfT (measureDs mt c n) t--stats :: (Semigroup t) => [Double] -> Int -> PerfT IO t [[Double]]-stats xs l = do- r1 <- ffap "stats" (scan ((,) <$> ma 0.99 <*> std 0.99)) (take l xs)- r2 <- ffap "ma" (scan (ma 0.99)) xs- r3 <- ffap "std" (scan (std 0.99)) xs- pure [fst <$> r1, snd <$> r1, r2, r3]--perfQuantiles :: (Semigroup t) => [Double] -> [Double] -> Int -> PerfT IO t [Int]-perfQuantiles qs xs l = do- r1 <- ffap "digitize" (scan (digitize 0.99 qs)) (take l xs)- r2 <- ffap "digitize'" (scan (digitize' 0.99 qs)) (take l xs)- pure (r1 <> r2)--digitize' :: Double -> [Double] -> Mealy Double Int-digitize' r qs = M inject step' extract- where- step' (x, _) a = (onlineInsert a x, a)- inject a = (onlineInsert a (emptyOnlineTDigest r), a)- extract (x, l) = bucket' qs' l- where- qs' = fromMaybe (0 / 0) . (`quantile` t) <$> qs- (OnlineTDigest t _ _) = onlineCompress x- bucket' xs l' =- fold (M id (+) id) $- ( \x' ->- if x' > l'- then 0- else 1- )- <$> xs