-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Benchmarking, Performance, Testing -- -- This library provides a powerful but simple way to measure the -- performance of Haskell code. It provides both a framework for -- executing and analysing benchmarks and a set of driver functions that -- makes it easy to build and run benchmarks, and to analyse their -- results. -- -- The fastest way to get started is to read the documentation and -- examples in the Criterion.Main module. @package criterion @version 0.1.2 module Criterion.MultiMap data MultiMap k v fromMap :: Map k (Set v) -> MultiMap k v toMap :: MultiMap k v -> Map k (Set v) singleton :: k -> v -> MultiMap k v lookup :: (Ord k, Ord v) => k -> MultiMap k v -> Maybe (Set v) instance (Eq k, Eq v) => Eq (MultiMap k v) instance (Ord k, Ord v) => Ord (MultiMap k v) instance (Ord k, Ord v, Read k, Read v) => Read (MultiMap k v) instance (Show k, Show v) => Show (MultiMap k v) instance (Ord k, Ord v) => Monoid (MultiMap k v) -- | Types for benchmarking. -- -- The core class is Benchmarkable, which admits both pure -- functions and IO actions. -- -- For a pure function of type Int -> a, the benchmarking -- harness calls this function repeatedly, each time with a different -- Int argument, and reduces the result the function returns to -- weak head normal form. If you need the result reduced to normal form, -- that is your responsibility. -- -- For an action of type IO a, the benchmarking harness calls -- the action repeatedly, but does not reduce the result. module Criterion.Types -- | A benchmarkable function or action. class Benchmarkable b run :: (Benchmarkable b) => b -> Int -> IO () -- | A benchmark may consist of either a single Benchmarkable item -- with a name, created with bench, or a (possibly nested) group -- of Benchmarks, created with bgroup. data Benchmark Benchmark :: String -> b -> Benchmark BenchGroup :: String -> [Benchmark] -> Benchmark -- | Create a single benchmark. bench :: (Benchmarkable b) => String -> b -> Benchmark -- | Group several benchmarks together under a common name. bgroup :: String -> [Benchmark] -> Benchmark -- | Retrieve the names of all benchmarks. Grouped benchmarks are prefixed -- with the name of the group they're in. benchNames :: Benchmark -> [String] instance Show Benchmark instance Benchmarkable (IO a) instance Benchmarkable (Int -> a) module Criterion.Measurement getTime :: IO Double runForAtLeast :: Double -> Int -> (Int -> IO a) -> IO ((Double :*: Int) :*: a) secs :: Double -> String time :: IO a -> IO (Double :*: a) time_ :: IO a -> IO Double -- | Benchmarking configuration. module Criterion.Config -- | Top-level program configuration. data Config Config :: Last String -> Last Double -> Last Bool -> MultiMap Plot PlotOutput -> PrintExit -> Last Int -> Last Int -> Last Verbosity -> Config -- | The "version" banner to print. cfgBanner :: Config -> Last String -- | Confidence interval to use. cfgConfInterval :: Config -> Last Double -- | Whether to run the GC between passes. cfgPerformGC :: Config -> Last Bool -- | What to plot, and where. cfgPlot :: Config -> MultiMap Plot PlotOutput -- | Whether to print information and exit. cfgPrintExit :: Config -> PrintExit -- | Number of resamples to perform. cfgResamples :: Config -> Last Int -- | Number of samples to collect. cfgSamples :: Config -> Last Int -- | Whether to run verbosely. cfgVerbosity :: Config -> Last Verbosity -- | Supported plot outputs. Some outputs support width and height in -- varying units. A point is 1/72 of an inch (0.353mm). data PlotOutput -- | Textual CSV file. CSV :: PlotOutput -- | PDF file, dimensions in points. PDF :: Int -> Int -> PlotOutput -- | PNG file, dimensions in pixels. PNG :: Int -> Int -> PlotOutput -- | SVG file, dimensions in points. SVG :: Int -> Int -> PlotOutput -- | Display in a window, dimensions in pixels. Window :: Int -> Int -> PlotOutput -- | What to plot. data Plot -- | Kernel density estimate of probabilities. KernelDensity :: Plot -- | Benchmark timings. Timing :: Plot -- | Print some information and exit, without running any benchmarks. data PrintExit -- | Do not actually print-and-exit. (Default.) Nada :: PrintExit -- | Print a list of known benchmarks. List :: PrintExit -- | Print version information (if known). Version :: PrintExit -- | Print a help/usaage message. Help :: PrintExit -- | Control the amount of information displayed. data Verbosity Quiet :: Verbosity Normal :: Verbosity Verbose :: Verbosity -- | A configuration with sensible defaults. defaultConfig :: Config -- | Deconstructor for Last values. fromLJ :: (Config -> Last a) -> Config -> a -- | Constructor for Last values. ljust :: a -> Last a instance Typeable Config instance Typeable Plot instance Typeable PlotOutput instance Typeable PrintExit instance Typeable Verbosity instance Eq Config instance Read Config instance Show Config instance Eq Plot instance Ord Plot instance Read Plot instance Show Plot instance Eq PlotOutput instance Ord PlotOutput instance Read PlotOutput instance Show PlotOutput instance Eq PrintExit instance Ord PrintExit instance Bounded PrintExit instance Enum PrintExit instance Read PrintExit instance Show PrintExit instance Eq Verbosity instance Ord Verbosity instance Bounded Verbosity instance Enum Verbosity instance Read Verbosity instance Show Verbosity instance Monoid Config instance Monoid PrintExit -- | Input and output actions. module Criterion.IO -- | A typeclass hack to match that of the HPrintfType class. class NoOp a -- | Print a "normal" note. note :: (HPrintfType r, NoOp r) => Config -> String -> r -- | Print an error message. printError :: (HPrintfType r) => String -> r -- | Print verbose output. prolix :: (HPrintfType r, NoOp r) => Config -> String -> r instance (NoOp r) => NoOp (a -> r) instance NoOp (IO a) -- | Plotting functions. module Criterion.Plot -- | Plot kernel density estimate. plotKDE :: PlotOutput -> String -> Points -> UArr Double -> IO () -- | Plot timing data. plotTiming :: PlotOutput -> String -> Sample -> IO () plotWith :: Plot -> Config -> (PlotOutput -> IO ()) -> IO () -- | Analysis code for benchmarks. module Criterion.Analysis -- | Outliers from sample data, calculated using the boxplot technique. data Outliers Outliers :: !!Int64 -> !!Int64 -> !!Int64 -> !!Int64 -> !!Int64 -> Outliers samplesSeen :: Outliers -> !!Int64 -- | More than 3 times the IQR below the first quartile. lowSevere :: Outliers -> !!Int64 -- | Between 1.5 and 3 times the IQR below the first quartile. lowMild :: Outliers -> !!Int64 -- | Between 1.5 and 3 times the IQR above the third quartile. highMild :: Outliers -> !!Int64 -- | More than 3 times the IQR above the third quartile. highSevere :: Outliers -> !!Int64 -- | A description of the extent to which outliers in the sample data -- affect the sample mean and standard deviation. data OutlierVariance -- | Less than 1% effect. Unaffected :: OutlierVariance -- | Between 1% and 10%. Slight :: OutlierVariance -- | Between 10% and 50%. Moderate :: OutlierVariance -- | Above 50% (i.e. measurements are useless). Severe :: OutlierVariance -- | Display the mean of a Sample, and characterise the outliers -- present in the sample. analyseMean :: Config -> Sample -> Int -> IO Double -- | Count the total number of outliers in a sample. countOutliers :: Outliers -> Int64 -- | Classify outliers in a data set, using the boxplot technique. classifyOutliers :: Sample -> Outliers -- | Display a report of the Outliers present in a Sample. noteOutliers :: Config -> Outliers -> IO () -- | Compute the extent to which outliers in the sample data affect the -- sample mean and standard deviation. outlierVariance :: Estimate -> Estimate -> Double -> (OutlierVariance, Double) instance Eq OutlierVariance instance Ord OutlierVariance instance Show OutlierVariance instance Eq Outliers instance Read Outliers instance Show Outliers instance Monoid Outliers -- | Code for measuring and characterising the execution environment. module Criterion.Environment -- | Measured aspects of the execution environment. data Environment Environment :: !!Double -> !!Double -> Environment -- | Clock resolution (in seconds). envClockResolution :: Environment -> !!Double -- | The cost of a single clock call (in seconds). envClockCost :: Environment -> !!Double -- | Measure the execution environment. measureEnvironment :: Config -> IO Environment instance Typeable Environment instance Eq Environment instance Read Environment instance Show Environment -- | Core benchmarking code. module Criterion -- | A benchmarkable function or action. class Benchmarkable b run :: (Benchmarkable b) => b -> Int -> IO () -- | A benchmark may consist of either a single Benchmarkable item -- with a name, created with bench, or a (possibly nested) group -- of Benchmarks, created with bgroup. data Benchmark -- | Create a single benchmark. bench :: (Benchmarkable b) => String -> b -> Benchmark -- | Group several benchmarks together under a common name. bgroup :: String -> [Benchmark] -> Benchmark -- | Run a single benchmark, and return timings measured when executing it. runBenchmark :: (Benchmarkable b) => Config -> Environment -> b -> IO Sample -- | Run, and analyse, one or more benchmarks. runAndAnalyse :: (String -> Bool) -> Config -> Environment -> Benchmark -> IO () -- | Wrappers for compiling and running benchmarks quickly and easily. See -- defaultMain below for an example. module Criterion.Main -- | A benchmarkable function or action. class Benchmarkable b run :: (Benchmarkable b) => b -> Int -> IO () -- | A benchmark may consist of either a single Benchmarkable item -- with a name, created with bench, or a (possibly nested) group -- of Benchmarks, created with bgroup. data Benchmark -- | Create a single benchmark. bench :: (Benchmarkable b) => String -> b -> Benchmark -- | Group several benchmarks together under a common name. bgroup :: String -> [Benchmark] -> Benchmark -- | An entry point that can be used as a main function. -- --
--   import Criterion.Main
--   
--   fib :: Int -> Int
--   fib 0 = 0
--   fib 1 = 1
--   fib n = fib (n-1) + fib (n-2)
--   
--   main = defaultMain [
--          bgroup "fib" [ bench "fib 10" $ \n -> fib (10+n-n))
--                       , bench "fib 35" $ \n -> fib (35+n-n))
--                       , bench "fib 37" $ \n -> fib (37+n-n))
--                       ]
--                      ]
--   
defaultMain :: [Benchmark] -> IO () -- | An entry point that can be used as a main function, with -- configurable defaults. -- -- Example: -- --
--   import Criterion.Config
--   import qualified Criterion.MultiMap as M
--   
--   myConfig = defaultConfig {
--                -- Always display an 800x600 window with curves.
--                cfgPlot = M.singleton KernelDensity (Window 800 600)
--              }
--   
--   main = defaultMainWith myConfig [
--            bench "fib 30" $ \(n::Int) -> fib (30+n-n)
--          ]
--   
-- -- If you save the above example as "Fib.hs", you should be able -- to compile it as follows: -- --
--   ghc -O --make Fib
--   
-- -- Run "Fib --help" on the command line to get a list of command -- line options. defaultMainWith :: Config -> [Benchmark] -> IO () -- | The standard options accepted on the command line. defaultOptions :: [OptDescr (IO Config)] -- | Parse command line options. parseArgs :: Config -> [OptDescr (IO Config)] -> [String] -> IO (Config, [String])