perf-0.10.3: Low-level run time measurement.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Perf.Algos

Description

Algorithms and functions for testing purposes

Synopsis

command-line options

data Example Source #

Algorithm examples for testing

Instances

Instances details
Show Example Source # 
Instance details

Defined in Perf.Algos

Eq Example Source # 
Instance details

Defined in Perf.Algos

Methods

(==) :: Example -> Example -> Bool #

(/=) :: Example -> Example -> Bool #

allExamples :: [Example] Source #

All the example algorithms.

parseExample :: Parser Example Source #

Parse command-line options for algorithm examples.

data ExamplePattern a Source #

Unification of example function applications

Constructors

PatternSumFuse Text (Num a => a -> a) a 
PatternSum Text (Num a => [a] -> a) [a] 
PatternLengthF Text ([a] -> Int) [a] 
PatternConstFuse Text (Int -> ()) Int 
PatternMapInc Text ([Int] -> [Int]) [Int] 
PatternNoOp Text (() -> ()) () 

statExamples :: MonadIO m => Int -> Int -> (Int -> Measure m [a]) -> m (Map Text [a]) Source #

run an example measurement.

sum algorithms

data SumPattern a Source #

Unification of sum function applications

Constructors

SumFuse Text (Int -> Int) Int 
SumFusePoly Text ((Enum a, Num a) => a -> a) a 
SumPoly Text (Num a => [a] -> a) [a] 
SumMono Text ([Int] -> Int) [Int] 

allSums :: Int -> [SumPattern Int] Source #

All the sum algorithms.

testSum :: (Semigroup a, MonadIO m) => SumPattern Int -> PerfT m a Int Source #

Convert an SumPattern to a PerfT.

statSums :: MonadIO m => Int -> Int -> (Int -> Measure m [a]) -> m (Map Text [a]) Source #

Run a sum algorithm measurement.

sumTail :: Num a => [a] -> a Source #

tail resursive

sumTailLazy :: Num a => [a] -> a Source #

lazy recursion.

sumFlip :: Num a => [a] -> a Source #

With argument order flipped

sumFlipLazy :: Num a => [a] -> a Source #

Lazy with argument order flipped.

sumCo :: Num a => [a] -> a Source #

Co-routine style

sumCoGo :: Num a => [a] -> a Source #

Co-routine, go style

sumCoCase :: Num a => [a] -> a Source #

Co-routine, case-style

sumAux :: Num a => [a] -> a Source #

Auxillary style.

sumFoldr :: Num a => [a] -> a Source #

foldr style

sumCata :: Num a => [a] -> a Source #

cata style

sumSum :: Num a => [a] -> a Source #

sum

sumMono :: [Int] -> Int Source #

Monomorphic sum

sumPoly :: Num a => [a] -> a Source #

Polymorphic sum

sumLambda :: Num a => [a] -> a Source #

Lambda-style sum

sumF :: Num a => [a] -> a Source #

GHC-style foldr method.

sumFuse :: Int -> Int Source #

Fusion check

sumFusePoly :: (Enum a, Num a) => a -> a Source #

Fusion under polymorph

sumFuseFoldl' :: Int -> Int Source #

foldl' fusion

sumFuseFoldr :: Int -> Int Source #

foldr fusion

length algorithms

data LengthPattern a Source #

Unification of length function applications

Constructors

LengthPoly Text ([a] -> Int) [a] 
LengthMono Text ([Int] -> Int) [Int] 

allLengths :: Int -> [LengthPattern Int] Source #

All the length algorithms.

statLengths :: MonadIO m => Int -> Int -> (Int -> Measure m [a]) -> m (Map Text [a]) Source #

Run a lengths algorithm

length

lengthTail :: [a] -> Int Source #

tail resursive

lengthTailLazy :: [a] -> Int Source #

lazy recursion.

lengthFlip :: [a] -> Int Source #

With argument order flipped

lengthFlipLazy :: [a] -> Int Source #

Lazy with argument order flipped.

lengthCo :: [a] -> Int Source #

Co-routine style

lengthCoCase :: [a] -> Int Source #

Co-routine style as a Case statement.

lengthAux :: [a] -> Int Source #

Auxillary version.

lengthFoldr :: [a] -> Int Source #

foldr style

lengthFoldrConst :: [a] -> Int Source #

foldr style with explicit const usage.

lengthF :: [a] -> Int Source #

GHC style

lengthFMono :: [Int] -> Int Source #

Monomorphic, GHC style

recursion patterns

recurseTail :: (a -> b -> b) -> b -> [a] -> b Source #

Tail recursion

recurseTailLazy :: (a -> b -> b) -> b -> [a] -> b Source #

Lazy tail recursion

recurseFlip :: (a -> b -> b) -> b -> [a] -> b Source #

Tail resursion with flipped argument order.

recurseFlipLazy :: (a -> b -> b) -> b -> [a] -> b Source #

Lazy tail resursion with flipped argument order.

recurseCo :: (a -> b -> b) -> b -> [a] -> b Source #

Coroutine

recurseCoLazy :: (a -> b -> b) -> b -> [a] -> b Source #

Lazy, coroutine

recurseCata :: (a -> b -> b) -> b -> [a] -> b Source #

Cata style

miscellaneous

mapInc :: [Int] -> [Int] Source #

Increment a list.

constFuse :: Int -> () Source #

Test of const fusion

splitHalf :: [a] -> ([a], [a]) Source #

Split a list.