on master help sign in
Make it portable for tasty-bench+streaming-benchmarks
ce8c5dfHarendra Kumar
benchmark/bench-report/BenchReport.hs+20−7
@@ -28,6 +28,7 @@ data BenchType
28data Options = Options
28data Options = Options
29 { genGraphs :: Bool
29 { genGraphs :: Bool
30 , sortByName :: Bool
30 , sortByName :: Bool
31+ , useGauge :: Bool
31 , benchType :: Maybe BenchType
32 , benchType :: Maybe BenchType
32 , fields :: [String]
33 , fields :: [String]
33 , diffStyle :: GroupStyle
34 , diffStyle :: GroupStyle
@@ -35,7 +36,7 @@ data Options = Options
35 } deriving Show
36 } deriving Show
36
37
37defaultOptions :: Options
38defaultOptions :: Options
38−defaultOptions = Options False False Nothing ["time"] PercentDiff 0
39+defaultOptions = Options False False False Nothing ["time"] PercentDiff 0
39
40
40setGenGraphs :: Monad m => Bool -> StateT (a, Options) m ()
41setGenGraphs :: Monad m => Bool -> StateT (a, Options) m ()
41setGenGraphs val = do
42setGenGraphs val = do
@@ -47,6 +48,11 @@ setSortByName val = do
47 (args, opts) <- get
48 (args, opts) <- get
48 put (args, opts { sortByName = val })
49 put (args, opts { sortByName = val })
49
50
51+setUseGauge :: Monad m => Bool -> StateT (a, Options) m ()
52+setUseGauge val = do
53+ (args, opts) <- get
54+ put (args, opts { useGauge = val })
55+
50setBenchType :: Monad m => BenchType -> StateT (a, Options) m ()
56setBenchType :: Monad m => BenchType -> StateT (a, Options) m ()
51setBenchType val = do
57setBenchType val = do
52 (args, opts) <- get
58 (args, opts) <- get
@@ -135,6 +141,7 @@ parseOptions = do
135 case opt of
141 case opt of
136 "--graphs" -> setGenGraphs True
142 "--graphs" -> setGenGraphs True
137 "--sort-by-name" -> setSortByName True
143 "--sort-by-name" -> setSortByName True
144+ "--use-gauge" -> setUseGauge True
138 "--benchmark" -> parseBench
145 "--benchmark" -> parseBench
139 "--fields" -> parseFields
146 "--fields" -> parseFields
140 "--diff-style" -> parseDiff
147 "--diff-style" -> parseDiff
@@ -177,12 +184,18 @@ showComparisons Options{..} cfg inp out =
177
184
178 where
185 where
179
186
187+ separator = if useGauge then '/' else '.'
180− dropComponent = dropWhile (== '/') . dropWhile (/= '/')
188+ dropComponent = dropWhile (== separator) . dropWhile (/= separator)
181−
189+
182− classifyComparison b = Just
190+ classifyComparison b =
191+ let b1 =
192+ if useGauge
193+ then b
194+ else dropComponent b --- drop "All." at the beginning
195+ in Just
183− ( takeWhile (/= '/') b
196+ ( takeWhile (/= separator) b1
184− , dropComponent b
197+ , dropComponent b1
185− )
198+ )
186
199
187------------------------------------------------------------------------------
200------------------------------------------------------------------------------
188-- text reports
201-- text reports
benchmark/bench-report/bin/bench-runner.sh+19−5
@@ -178,15 +178,28 @@ bench_exec_one() {
178 local BENCH_NAME1
178 local BENCH_NAME1
179 local BENCH_NAME2
179 local BENCH_NAME2
180 local BENCH_NAME
180 local BENCH_NAME
181+ # XXX this is a hack to make the "/" separated names used in the functions
182+ # determining options based on benchmark name. For tasty-bench the benchmark
183+ # names are separated by "." instead of "/".
181 if test "$USE_GAUGE" -eq 0
184 if test "$USE_GAUGE" -eq 0
182 then
185 then
183− # XXX this is a hack to make the "/" separated names used in the functions
186+ # Remove the prefix "All."
184− # determining options based on benchmark name. For tasty-bench the benchmark
185− # names are separated by "." instead of "/".
186 BENCH_NAME0=$(echo $BENCH_NAME_ORIG | sed -e s/^All\.//)
187 BENCH_NAME0=$(echo $BENCH_NAME_ORIG | sed -e s/^All\.//)
188+
189+ # Module names could contain dots e.g. "Prelude.Serial". So we insert
190+ # an explicit "/" to separate the module name part and the rest of
191+ # the benchmark name. For example, Prelude.Serial/elimination.drain
187 BENCH_NAME1=$(echo $BENCH_NAME0 | cut -f1 -d '/')
192 BENCH_NAME1=$(echo $BENCH_NAME0 | cut -f1 -d '/')
193+
194+ if test "$BENCH_NAME1" = "$BENCH_NAME0"
195+ then
196+ # There is no "/" separator
197+ BENCH_NAME1=$(echo $BENCH_NAME0 | sed -e 's/\./\//g')
198+ BENCH_NAME2=""
199+ else
188− BENCH_NAME2=$(echo $BENCH_NAME0 | cut -f2- -d '/' | sed -e 's/\./\//g')
200+ BENCH_NAME2=/$(echo $BENCH_NAME0 | cut -f2- -d '/' | sed -e 's/\./\//g')
201+ fi
189− BENCH_NAME="$BENCH_NAME1/$BENCH_NAME2"
202+ BENCH_NAME="${BENCH_NAME1}${BENCH_NAME2}"
190 else
203 else
191 BENCH_NAME=$BENCH_NAME_ORIG
204 BENCH_NAME=$BENCH_NAME_ORIG
192 fi
205 fi
@@ -419,6 +432,7 @@ run_reports() {
419 echo "Generating reports for ${i}..."
432 echo "Generating reports for ${i}..."
420 $prog \
433 $prog \
421 --benchmark $i \
434 --benchmark $i \
435+ $(test "$USE_GAUGE" = 1 && echo "--use-gauge") \
422 $(test "$GRAPH" = 1 && echo "--graphs") \
436 $(test "$GRAPH" = 1 && echo "--graphs") \
423 $(test "$SORT_BY_NAME" = 1 && echo "--sort-by-name") \
437 $(test "$SORT_BY_NAME" = 1 && echo "--sort-by-name") \
424 $(test -n "$BENCH_DIFF_STYLE" && echo "--diff-style $BENCH_DIFF_STYLE") \
438 $(test -n "$BENCH_DIFF_STYLE" && echo "--diff-style $BENCH_DIFF_STYLE") \