-- 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.12.0.1
-- | 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.
--
--
-- - measure applies a function to a value, returning a tuple of the
-- performance measure, and the computation result.
-- - measureM evaluates a monadic value and returns a
-- performance-result tuple.
--
data Measure m t
Measure :: (forall a b. (a -> b) -> a -> m (t, b)) -> (forall a. m a -> m (t, a)) -> Measure m t
[measure] :: Measure m t -> forall a b. (a -> b) -> a -> m (t, b)
[measureM] :: Measure m t -> forall a. m a -> m (t, a)
-- | Convert a Measure into a multi measure.
repeated :: Applicative m => Int -> Measure m t -> Measure m [t]
-- | Abstraction of a performance measurement with a pre and a post step
-- wrapping the computation.
data StepMeasure m t
StepMeasure :: m i -> (i -> m t) -> StepMeasure m t
[pre] :: StepMeasure m t -> m i
[post] :: StepMeasure m t -> i -> m t
-- | Convert a StepMeasure into a Measure
toMeasure :: Monad m => StepMeasure m t -> Measure m t
-- | Convert a StepMeasure into a Measure running the computation multiple
-- times.
toMeasureN :: Monad m => Int -> StepMeasure m t -> Measure m [t]
-- | A single step measurement.
step :: Monad m => m i -> (i -> m t) -> (a -> b) -> a -> m (t, b)
-- | A single step measurement.
stepM :: Monad m => m i -> (i -> m t) -> m a -> m (t, a)
-- | Multiple measurement
multi :: Monad m => ((a -> b) -> a -> m (t, b)) -> Int -> (a -> b) -> a -> m ([t], b)
-- | Multiple measurements
multiM :: Monad m => (m a -> m (t, a)) -> Int -> m a -> m ([t], a)
-- | Lift an application to a PerfT m, providing a label and a
-- Measure.
--
-- Measurements with the same label will be mappended
fap :: (MonadIO m, Semigroup t) => Text -> (a -> b) -> a -> PerfT m t b
-- | Lift an application to a PerfT m, forcing the argument.
afap :: (NFData a, MonadIO m, Semigroup t) => Text -> (a -> b) -> a -> PerfT m t b
-- | Lift an application to a PerfT m, forcing argument and result.
ffap :: (NFData a, NFData b, MonadIO m, Semigroup t) => Text -> (a -> b) -> a -> PerfT m t b
-- | Lift a number to a PerfT m, providing a label, function, and input.
--
-- Measurements with the same label will be added
fan :: (MonadIO m, Num t) => Text -> (a -> b) -> a -> PerfT m t b
-- | Lift a monadic value to a PerfT m, providing a label and a
-- Measure.
--
-- Measurements with the same label will be added
fam :: (MonadIO m, Semigroup t) => Text -> m a -> PerfT m t a
-- | lift a pure, unnamed function application to PerfT
(|$|) :: Semigroup t => (a -> b) -> a -> PerfT IO t b
-- | lift a monadic, unnamed function application to PerfT
($|) :: Semigroup t => IO a -> PerfT IO t a
-- | lift an unnamed numeric measure to PerfT
(|+|) :: Num t => (a -> b) -> a -> PerfT IO t b
-- | Performance measurement transformer storing a Measure and a map
-- of named results.
newtype PerfT m t a
PerfT :: StateT (Measure m t, Map Text t) m a -> PerfT m t a
[measurePerf] :: PerfT m t a -> StateT (Measure m t, Map Text t) m a
-- | The transformer over Identity
type Perf t a = PerfT Identity t a
-- | Run the performance measure, returning (computational result,
-- measurement).
runPerfT :: Functor m => Measure m t -> PerfT m t a -> m (a, Map Text t)
-- | Consume the PerfT layer and return the original monadic result.
-- Fingers crossed, PerfT structure should be completely compiled away.
evalPerfT :: Monad m => Measure m t -> PerfT m t a -> m a
-- | Consume a PerfT layer and return the measurement.
execPerfT :: Monad m => Measure m t -> PerfT m t a -> m (Map Text t)
-- | run a PerfT and also calculate performance over the entire computation
outer :: (MonadIO m, Semigroup s) => Text -> Measure m s -> Measure m t -> PerfT m t a -> m (a, (Map Text s, Map Text t))
-- | run a PerfT and calculate excess performance over the entire
-- computation
slop :: (MonadIO m, Num t, Semigroup t) => Text -> Measure m t -> PerfT m t a -> m (a, Map Text t)
-- | run a multi PerfT and calculate excess performance over the entire
-- computation
slops :: (MonadIO m, Num t, Semigroup t) => Int -> Measure m t -> PerfT m [t] a -> m (a, (Map Text t, Map Text [t]))
instance GHC.Base.Monad m => GHC.Base.Monad (Perf.Types.PerfT m t)
instance GHC.Base.Monad m => GHC.Base.Applicative (Perf.Types.PerfT m t)
instance GHC.Base.Functor m => GHC.Base.Functor (Perf.Types.PerfT m t)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Perf.Types.PerfT m t)
instance GHC.Base.Functor m => GHC.Base.Functor (Perf.Types.StepMeasure m)
instance GHC.Base.Applicative m => GHC.Base.Applicative (Perf.Types.StepMeasure m)
instance GHC.Base.Functor m => GHC.Base.Functor (Perf.Types.Measure m)
instance GHC.Base.Applicative m => GHC.Base.Applicative (Perf.Types.Measure m)
-- | tick uses the rdtsc chipset to measure time performance of a
-- computation.
--
-- The measurement unit is one oscillation of the chip crystal as
-- measured by the rdtsc instruction which inspects the TSC
-- register.
--
-- For reference, a computer with a frequency of 2 GHz means that one
-- cycle is equivalent to 0.5 nanoseconds.
module Perf.Time
-- | tick_ measures the number of cycles it takes to read the rdtsc chip
-- twice: the difference is then how long it took to read the clock the
-- second time.
tick_ :: IO Cycles
-- | Warm up the register, to avoid a high first measurement. Without a
-- warmup, one or more larger values can occur at the start of a
-- measurement spree, and often are in the zone of an L2 miss.
warmup :: Int -> IO ()
-- | tick f a
--
--
-- - strictly evaluates f and a to WHNF
-- - starts the cycle counter
-- - strictly evaluates f a to WHNF
-- - stops the cycle counter
-- - returns (number of cycles, f a)
--
tick :: (a -> b) -> a -> IO (Cycles, b)
-- | tickWHNF f a
--
--
-- - starts the cycle counter
-- - strictly evaluates f a to WHNF (this may also kick off thunk
-- evaluation in f or a which will also be captured in the cycle
-- count)
-- - stops the cycle counter
-- - returns (number of cycles, f a)
--
tickWHNF :: (a -> b) -> a -> IO (Cycles, b)
-- | tickLazy f a
--
--
-- - starts the cycle counter
-- - lazily evaluates f a
-- - stops the cycle counter
-- - returns (number of cycles, f a)
--
tickLazy :: (a -> b) -> a -> IO (Cycles, b)
-- | tickForce f a
--
--
-- - deeply evaluates f and a,
-- - starts the cycle counter
-- - deeply evaluates f a
-- - stops the cycle counter
-- - returns (number of cycles, f a)
--
tickForce :: (NFData a, NFData b) => (a -> b) -> a -> IO (Cycles, b)
-- | tickForceArgs f a
--
--
-- - deeply evaluates f and a,
-- - starts the cycle counter
-- - strictly evaluates f a to WHNF
-- - stops the cycle counter
-- - returns (number of cycles, f a)
--
tickForceArgs :: NFData a => (a -> b) -> a -> IO (Cycles, b)
-- | measures an IO a
tickIO :: IO a -> IO (Cycles, a)
-- | n measurements of a tick
--
-- returns a list of Cycles and the last evaluated f a
ticks :: Int -> (a -> b) -> a -> IO ([Cycles], b)
-- | n measurements of a tickIO
--
-- returns an IO tuple; list of Cycles and the last evaluated f a
ticksIO :: Int -> IO a -> IO ([Cycles], a)
-- | Clock count.
newtype Cycles
Cycles :: Word64 -> Cycles
[word] :: Cycles -> Word64
-- | a measure using getCPUTime from System.CPUTime (unit is
-- picoseconds)
cputime :: StepMeasure IO Integer
-- | a measure using getCurrentTime (unit is seconds)
clocktime :: StepMeasure IO Double
-- | tick as a Measure
time :: Measure IO Cycles
-- | tick as a multi-Measure
times :: Int -> Measure IO [Cycles]
-- | tick as a StepMeasure
stepTime :: StepMeasure IO Cycles
instance GHC.Real.Integral Perf.Time.Cycles
instance GHC.Enum.Enum Perf.Time.Cycles
instance GHC.Real.Real Perf.Time.Cycles
instance GHC.Num.Num Perf.Time.Cycles
instance GHC.Classes.Ord Perf.Time.Cycles
instance GHC.Classes.Eq Perf.Time.Cycles
instance GHC.Read.Read Perf.Time.Cycles
instance GHC.Show.Show Perf.Time.Cycles
instance GHC.Base.Semigroup Perf.Time.Cycles
instance GHC.Base.Monoid Perf.Time.Cycles
-- | Space performance measurement.
module Perf.Space
-- | GHC allocation statistics.
data SpaceStats
SpaceStats :: Word64 -> Word32 -> Word64 -> Word64 -> Word64 -> SpaceStats
[allocatedBytes] :: SpaceStats -> Word64
[gcollects] :: SpaceStats -> Word32
[maxLiveBytes] :: SpaceStats -> Word64
[gcLiveBytes] :: SpaceStats -> Word64
[maxMem] :: SpaceStats -> Word64
-- | Convert SpaceStats to a list of numbers.
ssToList :: Num a => SpaceStats -> [a]
-- | Labels for SpaceStats.
spaceLabels :: [Text]
-- | A allocation StepMeasure with a flag to determine if
-- performGC should run prior to the measurement.
space :: Bool -> StepMeasure IO SpaceStats
-- | Measure memory allocation, with a flag to run performGC prior
-- to the measurement.
allocation :: Bool -> StepMeasure IO Bytes
-- | Number of bytes
newtype Bytes
Bytes :: Word64 -> Bytes
[unbytes] :: Bytes -> Word64
instance GHC.Classes.Eq Perf.Space.SpaceStats
instance GHC.Show.Show Perf.Space.SpaceStats
instance GHC.Read.Read Perf.Space.SpaceStats
instance GHC.Real.Integral Perf.Space.Bytes
instance GHC.Enum.Enum Perf.Space.Bytes
instance GHC.Real.Real Perf.Space.Bytes
instance GHC.Num.Num Perf.Space.Bytes
instance GHC.Classes.Ord Perf.Space.Bytes
instance GHC.Classes.Eq Perf.Space.Bytes
instance GHC.Read.Read Perf.Space.Bytes
instance GHC.Show.Show Perf.Space.Bytes
instance GHC.Base.Semigroup Perf.Space.Bytes
instance GHC.Base.Monoid Perf.Space.Bytes
instance GHC.Base.Semigroup Perf.Space.SpaceStats
instance GHC.Base.Monoid Perf.Space.SpaceStats
instance GHC.Num.Num Perf.Space.SpaceStats
-- | Simple counter.
module Perf.Count
-- | Register 1 as a performance measure
count :: Applicative m => StepMeasure m Int
-- | Count the number of times measured.
countN :: Int -> Measure IO Int
-- | Unification of the various different performance measure types, mostly
-- to unify reporting and data management.
module Perf.Measure
-- | Command-line measurement options.
data MeasureType
MeasureTime :: MeasureType
MeasureSpace :: MeasureType
MeasureSpaceTime :: MeasureType
MeasureAllocation :: MeasureType
MeasureCount :: MeasureType
-- | Parse command-line MeasureType options.
parseMeasure :: Parser MeasureType
-- | unification of the different measurements to being a list of doubles.
measureDs :: MeasureType -> Int -> Measure IO [[Double]]
-- | unification of the different measurements to being a list of doubles.
measureLabels :: MeasureType -> [Text]
-- | How to fold the list of performance measures.
measureFinalStat :: MeasureType -> [Double] -> Double
instance GHC.Show.Show Perf.Measure.MeasureType
instance GHC.Classes.Eq Perf.Measure.MeasureType
-- | Reporting on performance, potentially checking versus a canned
-- results.
module Perf.Report
-- | Benchmark name
type Name = String
-- | Whether to include header information.
data Header
Header :: Header
NoHeader :: Header
-- | Command-line parser for Header
parseHeader :: 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
-- | Options for production of a performance report.
data ReportOptions
ReportOptions :: Int -> StatDType -> MeasureType -> Golden -> Header -> CompareLevels -> ReportOptions
-- | Number of times to run a benchmark.
[reportN] :: ReportOptions -> Int
[reportStatDType] :: ReportOptions -> StatDType
[reportMeasureType] :: ReportOptions -> MeasureType
[reportGolden] :: ReportOptions -> Golden
[reportHeader] :: ReportOptions -> Header
[reportCompare] :: ReportOptions -> CompareLevels
-- | Default options
--
--
-- >>> defaultReportOptions
-- ReportOptions {reportN = 1000, 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:
--
--
-- - run a benchmark for summing the numbers 1 to a thousand.
-- - look for saved performance data in
-- other/foo-1000-MeasureTime-StatAverage.perf
-- - report on performance in isolation or versus the canned data file
-- if it exists.
-- - exit with failure if the performace had degraded.
--
reportMain :: Name -> PerfT IO [[Double]] a -> IO ()
-- | Run and report a benchmark to the console with the supplied options.
reportMainWith :: ReportOptions -> Name -> PerfT IO [[Double]] a -> IO ()
-- | Write results to file
writeResult :: FilePath -> Map [Text] Double -> IO ()
-- | Read results from a file.
readResult :: FilePath -> IO (Either String (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
-- | 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
-- | Default filepath is "other/bench.perf"
defaultGolden :: Golden
-- | Parse command-line golden file options.
parseGolden :: Parser Golden
-- | Replace the Golden file path with the suggested stem, but only if the
-- user did not specify a specific file path at the command line.
replaceDefaultFilePath :: FilePath -> ReportOptions -> ReportOptions
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.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
instance GHC.Generics.Generic Perf.Report.ReportOptions
instance GHC.Show.Show Perf.Report.ReportOptions
instance GHC.Classes.Eq Perf.Report.ReportOptions
-- | Order of complexity calculations.
--
-- References
--
--
module Perf.BigO
-- | order type
data O
-- | cubic
N3 :: O
-- | quadratic
N2 :: O
-- | ^3/2
N32 :: O
-- | N * log N
NLogN :: O
-- | linear
N1 :: O
-- | sqrt N
N12 :: O
-- | log N
LogN :: O
-- | constant
N0 :: O
-- | enumeration of O types
--
--
-- >>> 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
-- | Introduction
--
-- perf provides tools for measuring the runtime performance of
-- Haskell functions. It includes:
--
--
-- - time measurement via reading the RDTSC register (TSC stands for
-- "time stamp counter"), which is present on all x86 CPUs since the
-- Pentium architecture. For more details, see
-- https://en.wikipedia.org/wiki/Time_Stamp_Counter
-- - abstraction of what is a Measure so that the library
-- includes both space and time measurement with the same API.
-- - PerfT which is a monad transformer designed to add the
-- collection of performance information to existing code. Running the
-- code produces a tuple of the original computation results, and a Map
-- of performance measurements that were specified.
-- - functionality to determine performance order, in BigO
-- - reporting functionality in Report. perf can be run
-- via 'cabal bench'; see the project's cabal file for an example.
--
module Perf