-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Low-level run time measurement. -- -- A set of tools to measure performance of Haskell programs. See the -- Perf module for an example and full API documentation. @package perf @version 0.10.3 -- | Reporting on performance, potentially checking versus a canned -- results. module Perf.Report -- | Type of format for report data Format OrgMode :: Format ConsoleMode :: Format -- | Command-line parser for Format parseFormat :: Format -> Parser Format -- | Whether to include header information. data Header Header :: Header NoHeader :: Header -- | Command-line parser for Header parseHeader :: Header -> Parser Header -- | Levels of geometric difference in compared performance that triggers -- reporting. data CompareLevels CompareLevels :: Double -> Double -> Double -> CompareLevels [errorLevel] :: CompareLevels -> Double [warningLevel] :: CompareLevels -> Double [improvedLevel] :: CompareLevels -> Double -- |
-- >>> defaultCompareLevels
-- CompareLevels {errorLevel = 0.2, warningLevel = 5.0e-2, improvedLevel = 5.0e-2}
--
defaultCompareLevels :: CompareLevels
-- | Command-line parser for CompareLevels
parseCompareLevels :: CompareLevels -> Parser CompareLevels
-- | Report configuration options
data ReportConfig
ReportConfig :: Format -> Header -> CompareLevels -> ReportConfig
[format] :: ReportConfig -> Format
[includeHeader] :: ReportConfig -> Header
[levels] :: ReportConfig -> CompareLevels
-- |
-- >>> defaultReportConfig
-- ReportConfig {format = ConsoleMode, includeHeader = Header, levels = CompareLevels {errorLevel = 0.2, warningLevel = 5.0e-2, improvedLevel = 5.0e-2}}
--
defaultReportConfig :: ReportConfig
-- | Parse ReportConfig command line options.
parseReportConfig :: ReportConfig -> Parser ReportConfig
-- | Write results to file
writeResult :: FilePath -> Map [Text] Double -> IO ()
-- | Read results from file
readResult :: FilePath -> IO (Map [Text] Double)
-- | Comparison data between two results.
data CompareResult
CompareResult :: Maybe Double -> Maybe Double -> Text -> CompareResult
[oldResult] :: CompareResult -> Maybe Double
[newResult] :: CompareResult -> Maybe Double
[noteResult] :: CompareResult -> Text
-- | Compare two results and produce some notes given level triggers.
compareNote :: Ord a => CompareLevels -> Map a Double -> Map a Double -> Map a CompareResult
-- | Like intercalate, but on the outside as well.
outercalate :: Text -> [Text] -> Text
-- | Report to a console, comparing the measurement versus a canned file.
reportGolden :: ReportConfig -> FilePath -> Map [Text] Double -> IO ()
-- | Format a result as a table.
reportOrg2D :: Map [Text] Text -> IO ()
-- | Golden file options.
data Golden
Golden :: FilePath -> Bool -> Bool -> Golden
[golden] :: Golden -> FilePath
[check] :: Golden -> Bool
[record] :: Golden -> Bool
-- | Parse command-line golden file options.
parseGolden :: String -> Parser Golden
-- | Report results
report :: ReportConfig -> Golden -> [Text] -> Map [Text] [Double] -> IO ()
instance GHC.Generics.Generic Perf.Report.Format
instance GHC.Show.Show Perf.Report.Format
instance GHC.Classes.Eq Perf.Report.Format
instance GHC.Generics.Generic Perf.Report.Header
instance GHC.Show.Show Perf.Report.Header
instance GHC.Classes.Eq Perf.Report.Header
instance GHC.Show.Show Perf.Report.CompareLevels
instance GHC.Classes.Eq Perf.Report.CompareLevels
instance GHC.Generics.Generic Perf.Report.ReportConfig
instance GHC.Show.Show Perf.Report.ReportConfig
instance GHC.Classes.Eq Perf.Report.ReportConfig
instance GHC.Classes.Eq Perf.Report.CompareResult
instance GHC.Show.Show Perf.Report.CompareResult
instance GHC.Show.Show Perf.Report.Golden
instance GHC.Classes.Eq Perf.Report.Golden
instance GHC.Generics.Generic Perf.Report.Golden
-- | 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
-- | Compute the average time in seconds.
averageSecs :: [Double] -> Double
-- | Command-line options for type of statistic.
data StatDType
StatAverage :: StatDType
StatMedian :: StatDType
StatBest :: StatDType
StatSecs :: 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.
--
-- -- >>> 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 :: (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 :: MonadIO m => Int -> Int -> (Int -> Measure m [a]) -> m (Map Text [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 -- |