-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Performance methods and monad. -- -- A set of tools to measure performance of Haskell programs. See the -- Perf module and readme for an example and full API documentation. @package perf @version 0.13.0.0 -- | Statistical choices for multiple performance measurements. module Perf.Stats -- | Compute the average average :: [Double] -> Double -- | Compute the median median :: [Double] -> Double -- | Compute the tenth percentile tenth :: [Double] -> Double -- | Compute the average of an Integral averageI :: Integral a => [a] -> Double -- | Command-line options for type of statistic. data StatDType StatAverage :: StatDType StatMedian :: StatDType StatBest :: StatDType -- | Compute a statistic. statD :: StatDType -> [Double] -> Double -- | Compute a list of statistics. statDs :: StatDType -> [[Double]] -> [Double] -- | Parse command-line StatDType options. parseStatD :: Parser StatDType -- | Add a statistic to a State Map addStat :: (Ord k, Monad m) => k -> s -> StateT (Map k s) m () -- | Linguistic conversion of an ordinal ordy :: Int -> [Text] -- | Compute all stats. allStats :: Int -> Map [Text] [[Double]] -> Map [Text] [Double] -- | Convert a Map of performance result to a statistic. statify :: Ord a => StatDType -> Map a [[Double]] -> Map [a] [Double] instance GHC.Show.Show Perf.Stats.StatDType instance GHC.Classes.Eq Perf.Stats.StatDType -- | Abstract types of performance measurement. module Perf.Types -- | Abstraction of a performance measurement within a monadic context. -- --
-- >>> defaultCompareLevels
-- CompareLevels {errorLevel = 0.2, warningLevel = 5.0e-2, improvedLevel = 5.0e-2}
--
defaultCompareLevels :: CompareLevels
-- | Command-line parser for CompareLevels
parseCompareLevels :: CompareLevels -> Parser CompareLevels
-- | Options for production of a performance report.
data ReportOptions
ReportOptions :: Int -> Clock -> StatDType -> MeasureType -> Golden -> Header -> CompareLevels -> ReportOptions
-- | Number of times to run a benchmark.
[reportN] :: ReportOptions -> Int
[reportClock] :: ReportOptions -> Clock
[reportStatDType] :: ReportOptions -> StatDType
[reportMeasureType] :: ReportOptions -> MeasureType
[reportGolden] :: ReportOptions -> Golden
[reportHeader] :: ReportOptions -> Header
[reportCompare] :: ReportOptions -> CompareLevels
-- | Default options
--
--
-- >>> defaultReportOptions
-- ReportOptions {reportN = 1000, reportClock = MonotonicRaw, reportStatDType = StatAverage, reportMeasureType = MeasureTime, reportGolden = Golden {golden = "other/bench.perf", check = True, record = False}, reportHeader = Header, reportCompare = CompareLevels {errorLevel = 0.2, warningLevel = 5.0e-2, improvedLevel = 5.0e-2}}
--
defaultReportOptions :: ReportOptions
-- | Command-line parser for ReportOptions
parseReportOptions :: Parser ReportOptions
-- | Default command-line parser.
infoReportOptions :: ParserInfo ReportOptions
-- | Report results
--
-- If a goldenFile is checked, and performance has degraded, the function
-- will exit with ExitFailure so that 'cabal bench' and other
-- types of processes can signal performance issues.
report :: ReportOptions -> Map [Text] [Double] -> IO ()
-- | Run and report a benchmark to the console. For example,
--
-- reportMain "foo" (fap "sum" sum [1..1000]) would:
--
-- -- >>> olist -- [N3,N2,N32,NLogN,N1,N12,LogN,N0] --olist :: [O] -- | Calculate the expected performance measure -- --
-- >>> promote (order N2 1) 10 -- 100.0 --promote :: Order Double -> Double -> Double -- | Calculate the expected performance measure per n -- --
-- >>> promote (order N2 1) 10 -- 100.0 --promote1 :: Order Double -> Double -- | functions to compute performance measure -- --
-- >>> fmap ($ 0) promote_ -- [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0] ---- --
-- >>> fmap ($ 1) promote_ -- [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0] ---- -- Ordering makes sense around N=10 -- --
-- >>> fmap ($ 10) promote_ -- [1000.0,100.0,31.622776601683793,23.02585092994046,10.0,3.1622776601683795,2.302585092994046,1.0] ---- -- Having NP may cause big num problems -- --
-- >>> fmap ($ 1000) promote_ -- [1.0e9,1000000.0,31622.776601683792,6907.755278982137,1000.0,31.622776601683793,6.907755278982137,1.0] --promote_ :: [Double -> Double] -- | Calculate an Order from a given O, an n, and a total performance -- measurement -- -- A measurement of 1e6 for n=1000 with an order of N2 is: -- --
-- >>> demote N2 1000 1000000
-- Order {factors = [0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0]}
--
--
-- -- promote (demote N2 n m) n m == m --demote :: O -> Double -> Double -> Order Double -- | Calculate an Order from a measure, and an O -- --
-- >>> demote1 N2 1000
-- Order {factors = [0.0,1000.0,0.0,0.0,0.0,0.0,0.0,0.0]}
--
--
-- -- demote1 N2 m == demote o 1 m --demote1 :: O -> Double -> Order Double -- | The factor for each O given an n, and a measurement. -- --
-- >>> spectrum 100 10000
-- Order {factors = [1.0e-2,1.0,10.0,21.71472409516259,100.0,1000.0,2171.4724095162587,10000.0]}
--
spectrum :: Double -> Double -> Order Double
-- | a set of factors for each order, which represents a full Order
-- specification.
newtype Order a
Order :: [a] -> Order a
[factors] :: Order a -> [a]
-- | find the dominant order, and it's factor
--
-- -- >>> bigO o -- (N2,1.0) --bigO :: (Ord a, Num a) => Order a -> (O, a) -- | compute the runtime component of an Order, defined as the difference -- between the dominant order and the total for a single run. -- --
-- >>> runtime o -- 100.0 --runtime :: Order Double -> Double -- | A set of factors consisting of the dominant order, the dominant order -- factor and a constant factor data BigOrder a BigOrder :: O -> a -> a -> BigOrder a [bigOrder] :: BigOrder a -> O [bigFactor] :: BigOrder a -> a [bigConstant] :: BigOrder a -> a -- | compute the BigOrder -- --
-- >>> fromOrder o
-- BigOrder {bigOrder = N2, bigFactor = 1.0, bigConstant = 100.0}
--
fromOrder :: Order Double -> BigOrder Double
-- | convert a BigOrder to an Order.
--
-- toOrder . fromOrder is not a round trip iso.
--
--
-- >>> toOrder (fromOrder o)
-- Order {factors = [0.0,1.0,0.0,0.0,0.0,0.0,0.0,100.0]}
--
toOrder :: BigOrder Double -> Order Double
-- | create an Order
--
--
-- >>> order N2 1
-- Order {factors = [0,1,0,0,0,0,0,0]}
--
order :: Num a => O -> a -> Order a
-- | performance curve for a Measure.
mcurve :: Semigroup a => Measure IO a -> (Int -> b) -> [Int] -> IO [a]
-- | repetitive Double Meaure performance curve.
dcurve :: (Int -> Measure IO [Double]) -> StatDType -> Int -> (Int -> a) -> [Int] -> IO [Double]
-- | time performance curve.
tcurve :: StatDType -> Int -> (Int -> a) -> [Int] -> IO [Double]
-- | The errors for a list of n's and measurements, based on the spectrum
-- of the last measurement.
diffs :: [Double] -> [Double] -> [[Double]]
-- | minimum error order for a list of measurements
--
-- -- >>> bestO ns ms -- N1 --bestO :: [Double] -> [Double] -> O -- | fit the best order for the last measurement and return it, and the -- error terms for the measurements -- --
-- >>> estO ns ms
-- (Order {factors = [0.0,0.0,0.0,0.0,102.90746947660953,0.0,0.0,0.0]},[2702.0925305233905,2446.9253052339045,-301.7469476609531,-10317.469476609534,0.0])
--
estO :: [Double] -> [Double] -> (Order Double, [Double])
-- | fit orders from the last measurement to the first, using the residuals
-- at each step.
--
--
-- >>> estOs ns ms
-- [Order {factors = [0.0,0.0,0.0,0.0,102.90746947660953,0.0,0.0,0.0]},Order {factors = [0.0,0.0,-0.32626703235351473,0.0,0.0,0.0,0.0,0.0]},Order {factors = [0.0,0.0,0.0,0.0,0.0,0.0,0.0,24.520084692561625]},Order {factors = [0.0,0.0,0.0,0.0,0.0,0.0,0.0,2432.722690017952]},Order {factors = [0.0,0.0,0.0,0.0,0.0,0.0,0.0,245.1760228452299]}]
--
estOs :: [Double] -> [Double] -> [Order Double]
-- | BigOrder estimate
--
--
-- estOrder (\x -> sum [1..x]) 100 [1,10,100,1000,10000]
-- BigOrder {bigOrder = N1, bigFactor = 76.27652961460446, bigConstant = 0.0}
--
--
--
-- estOrder (\x -> sum $ nub [1..x]) 100 [1,10,100,1000]
-- BigOrder {bigOrder = N2, bigFactor = 13.485763594353541, bigConstant = 0.0}
--
estOrder :: (Int -> b) -> Int -> [Int] -> IO (BigOrder Double)
instance GHC.Enum.Enum Perf.BigO.O
instance GHC.Generics.Generic Perf.BigO.O
instance GHC.Show.Show Perf.BigO.O
instance GHC.Classes.Ord Perf.BigO.O
instance GHC.Classes.Eq Perf.BigO.O
instance GHC.Base.Functor Perf.BigO.Order
instance GHC.Generics.Generic (Perf.BigO.Order a)
instance GHC.Show.Show a => GHC.Show.Show (Perf.BigO.Order a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Perf.BigO.Order a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Perf.BigO.Order a)
instance GHC.Base.Functor Perf.BigO.BigOrder
instance GHC.Generics.Generic (Perf.BigO.BigOrder a)
instance GHC.Show.Show a => GHC.Show.Show (Perf.BigO.BigOrder a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Perf.BigO.BigOrder a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Perf.BigO.BigOrder a)
instance GHC.Num.Num a => GHC.Num.Num (Perf.BigO.Order a)
-- | Algorithms and functions for testing purposes
module Perf.Algos
-- | Algorithm examples for testing
data Example
ExampleSumFuse :: Example
ExampleSum :: Example
ExampleLengthF :: Example
ExampleConstFuse :: Example
ExampleMapInc :: Example
ExampleNoOp :: Example
-- | All the example algorithms.
allExamples :: [Example]
-- | Parse command-line options for algorithm examples.
parseExample :: Parser Example
-- | Unification of example function applications
data ExamplePattern a
PatternSumFuse :: Text -> (Num a => a -> a) -> a -> ExamplePattern a
PatternSum :: Text -> (Num a => [a] -> a) -> [a] -> ExamplePattern a
PatternLengthF :: Text -> ([a] -> Int) -> [a] -> ExamplePattern a
PatternConstFuse :: Text -> (Int -> ()) -> Int -> ExamplePattern a
PatternMapInc :: Text -> ([Int] -> [Int]) -> [Int] -> ExamplePattern a
PatternNoOp :: Text -> (() -> ()) -> () -> ExamplePattern a
-- | Convert an Example to an ExamplePattern.
examplePattern :: Example -> Int -> ExamplePattern Int
-- | Labels
exampleLabel :: ExamplePattern a -> Text
-- | Convert an ExamplePattern to a PerfT.
testExample :: (Semigroup a, MonadIO m) => ExamplePattern Int -> PerfT m a ()
-- | run an example measurement.
statExamples :: (Semigroup a, MonadIO m) => Int -> PerfT m a ()
-- | Unification of sum function applications
data SumPattern a
SumFuse :: Text -> (Int -> Int) -> Int -> SumPattern a
SumFusePoly :: Text -> ((Enum a, Num a) => a -> a) -> a -> SumPattern a
SumPoly :: Text -> (Num a => [a] -> a) -> [a] -> SumPattern a
SumMono :: Text -> ([Int] -> Int) -> [Int] -> SumPattern a
-- | All the sum algorithms.
allSums :: Int -> [SumPattern Int]
-- | Convert an SumPattern to a PerfT.
testSum :: (Semigroup a, MonadIO m) => SumPattern Int -> PerfT m a Int
-- | Run a sum algorithm measurement.
statSums :: MonadIO m => Int -> Int -> (Int -> Measure m [a]) -> m (Map Text [a])
-- | tail resursive
sumTail :: Num a => [a] -> a
-- | lazy recursion.
sumTailLazy :: Num a => [a] -> a
-- | With argument order flipped
sumFlip :: Num a => [a] -> a
-- | Lazy with argument order flipped.
sumFlipLazy :: Num a => [a] -> a
-- | Co-routine style
sumCo :: Num a => [a] -> a
-- | Co-routine, go style
sumCoGo :: Num a => [a] -> a
-- | Co-routine, case-style
sumCoCase :: Num a => [a] -> a
-- | Auxillary style.
sumAux :: Num a => [a] -> a
-- | foldr style
sumFoldr :: Num a => [a] -> a
-- | cata style
sumCata :: Num a => [a] -> a
-- | sum
sumSum :: Num a => [a] -> a
-- | Monomorphic sum
sumMono :: [Int] -> Int
-- | Polymorphic sum
sumPoly :: Num a => [a] -> a
-- | Lambda-style sum
sumLambda :: Num a => [a] -> a
-- | GHC-style foldr method.
sumF :: Num a => [a] -> a
-- | Fusion check
sumFuse :: Int -> Int
-- | Fusion under polymorph
sumFusePoly :: (Enum a, Num a) => a -> a
-- | foldl' fusion
sumFuseFoldl' :: Int -> Int
-- | foldr fusion
sumFuseFoldr :: Int -> Int
-- | Unification of length function applications
data LengthPattern a
LengthPoly :: Text -> ([a] -> Int) -> [a] -> LengthPattern a
LengthMono :: Text -> ([Int] -> Int) -> [Int] -> LengthPattern a
-- | All the length algorithms.
allLengths :: Int -> [LengthPattern Int]
-- | Convert an LengthPattern to a PerfT.
testLength :: (Semigroup a, MonadIO m) => LengthPattern Int -> PerfT m a Int
-- | Run a lengths algorithm
statLengths :: MonadIO m => Int -> Int -> (Int -> Measure m [a]) -> m (Map Text [a])
-- | tail resursive
lengthTail :: [a] -> Int
-- | lazy recursion.
lengthTailLazy :: [a] -> Int
-- | With argument order flipped
lengthFlip :: [a] -> Int
-- | Lazy with argument order flipped.
lengthFlipLazy :: [a] -> Int
-- | Co-routine style
lengthCo :: [a] -> Int
-- | Co-routine style as a Case statement.
lengthCoCase :: [a] -> Int
-- | Auxillary version.
lengthAux :: [a] -> Int
-- | foldr style
lengthFoldr :: [a] -> Int
-- | foldr style with explicit const usage.
lengthFoldrConst :: [a] -> Int
-- | GHC style
lengthF :: [a] -> Int
-- | Monomorphic, GHC style
lengthFMono :: [Int] -> Int
-- | Tail recursion
recurseTail :: (a -> b -> b) -> b -> [a] -> b
-- | Lazy tail recursion
recurseTailLazy :: (a -> b -> b) -> b -> [a] -> b
-- | Tail resursion with flipped argument order.
recurseFlip :: (a -> b -> b) -> b -> [a] -> b
-- | Lazy tail resursion with flipped argument order.
recurseFlipLazy :: (a -> b -> b) -> b -> [a] -> b
-- | Coroutine
recurseCo :: (a -> b -> b) -> b -> [a] -> b
-- | Lazy, coroutine
recurseCoLazy :: (a -> b -> b) -> b -> [a] -> b
-- | Cata style
recurseCata :: (a -> b -> b) -> b -> [a] -> b
-- | Increment a list.
mapInc :: [Int] -> [Int]
-- | Test of const fusion
constFuse :: Int -> ()
-- | Split a list.
splitHalf :: [a] -> ([a], [a])
instance GHC.Show.Show Perf.Algos.Example
instance GHC.Classes.Eq Perf.Algos.Example
-- |