bench-show 0.2.1 → 0.2.2
raw patch · 4 files changed
+47/−21 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ BenchShow: TitleDiff :: TitleAnnotation
+ BenchShow: TitleEstimator :: TitleAnnotation
+ BenchShow: TitleField :: TitleAnnotation
+ BenchShow: [titleAnnotations] :: Config -> [TitleAnnotation]
+ BenchShow: data TitleAnnotation
- BenchShow: Config :: Bool -> Maybe FilePath -> Maybe String -> Presentation -> Estimator -> Word -> DiffStrategy -> [String] -> [String] -> [(String, Double, Double)] -> [(String, FieldTick)] -> String -> Maybe (String, String) -> [(String, Int)] -> [(String, Int)] -> (SortColumn -> Either String [(String, Double)]) -> [String] -> Config
+ BenchShow: Config :: Bool -> Maybe FilePath -> Maybe String -> [TitleAnnotation] -> Presentation -> Estimator -> Word -> DiffStrategy -> [String] -> [String] -> [(String, Double, Double)] -> [(String, FieldTick)] -> String -> Maybe (String, String) -> [(String, Int)] -> [(String, Int)] -> (SortColumn -> Either String [(String, Double)]) -> [String] -> Config
Files
- Changelog.md +5/−0
- bench-show.cabal +2/−2
- lib/BenchShow.hs +1/−0
- lib/BenchShow/Common.hs +39/−19
Changelog.md view
@@ -1,3 +1,8 @@+## 0.2.2++* Allow additional annotations to title to be controlled via config+* Better error handling+ ## 0.2.1 * Use new version of `statistics` package.
bench-show.cabal view
@@ -1,5 +1,5 @@ name: bench-show-version: 0.2.1+version: 0.2.2 license: BSD3 author: Harendra Kumar maintainer: harendra.kumar@gmail.com@@ -55,7 +55,7 @@ category: Performance, Benchmarking homepage: https://github.com/composewell/bench-show license-file: LICENSE-tested-with: GHC==8.4.3+tested-with: GHC==8.4.4 , GHC==8.2.2 , GHC==7.10.3 copyright: 2017, 2018 Composewell Technologies
lib/BenchShow.hs view
@@ -85,6 +85,7 @@ module BenchShow ( GroupStyle(..) , Presentation(..)+ , TitleAnnotation (..) , Estimator (..) , DiffStrategy (..) , SortColumn (..)
lib/BenchShow/Common.hs view
@@ -20,6 +20,7 @@ , RelativeUnit (..) , Estimator (..) , DiffStrategy (..)+ , TitleAnnotation (..) , Config(..) , defaultConfig @@ -48,7 +49,7 @@ import Data.Function ((&), on) import Data.List (transpose, groupBy, (\\), find, sortBy, elemIndex, intersect,- intersectBy)+ intersectBy, concatMap) import Data.List.Split (linesBy) import Data.Maybe (fromMaybe, mapMaybe) import Data.Ord (comparing)@@ -175,6 +176,13 @@ | BestBest -} +-- | Additional annotations that can be optionally added to the title of the+-- report or graph.+--+-- @since 0.2.2+data TitleAnnotation = TitleField | TitleEstimator | TitleDiff+ deriving (Eq, Show)+ -- | Configuration governing generation of chart. See 'defaultConfig' for the -- default values of these fields. --@@ -193,6 +201,9 @@ -- the presentation style may be added to it. , title :: Maybe String + -- | Additional annotations to be added to the title+ , titleAnnotations :: [TitleAnnotation]+ -- | How to determine the layout of the report or the chart. , presentation :: Presentation @@ -269,6 +280,7 @@ -- @ -- verbose = False -- title = Nothing+-- titleAnnotations = [TitleField] -- outputDir = Nothing -- presentation = Groups Absolute -- estimator = Median@@ -287,6 +299,7 @@ defaultConfig = Config { verbose = False , title = Nothing+ , titleAnnotations = [TitleField] , outputDir = Nothing , presentation = Groups Absolute , estimator = Median@@ -498,18 +511,21 @@ -> (Int, BenchmarkMatrix) -> [GroupMatrix] splitGroup classify (serial, matrix@BenchmarkMatrix{..}) =- mapMaybe (\x -> fmap (,x) $ classify x) (map fst rowValues)- & sortBy (comparing (fst . fst))- & groupBy ((==) `on` (fst . fst))- & map (foldr foldGroup ("",[]))- & map sanityCheckGroup- & map (\(name, benches) ->- GroupMatrix- { groupIndex = serial- , groupName = name- , groupBenches = benches- , groupMatrix = matrix- })+ let classified = mapMaybe (\x -> fmap (,x) $ classify x) (map fst rowValues)+ in if null classified+ then error "No benchmarks were selected by \"classifyBenchmark\""+ else+ sortBy (comparing (fst . fst)) classified+ & groupBy ((==) `on` (fst . fst))+ & map (foldr foldGroup ("",[]))+ & map sanityCheckGroup+ & map (\(name, benches) ->+ GroupMatrix+ { groupIndex = serial+ , groupName = name+ , groupBenches = benches+ , groupMatrix = matrix+ }) where @@ -1233,11 +1249,15 @@ Median -> "Median" Regression -> "Regression Coeff." +addAnnotation :: String -> Maybe String -> Config -> TitleAnnotation -> String+addAnnotation field diff Config{..} annot =+ inParens+ $ case annot of+ TitleField -> field+ TitleEstimator -> showEstimator estimator+ TitleDiff -> maybe "" inParens diff+ makeTitle :: String -> Maybe String -> Config -> String-makeTitle field diff Config{..} =+makeTitle field diff cfg@Config{..} = fromMaybe "" title- ++ inParens field- ++ inParens (showEstimator estimator)- ++ case diff of- Nothing -> ""- Just str -> inParens str+ ++ concatMap (addAnnotation field diff cfg) titleAnnotations