on master help sign in
Make it portable for tasty-bench+streaming-benchmarks
commitce8c5df5fc6ae9ae5f19d6bcae086ca5052b3705 authorHarendra Kumar <harendra@composewell.com> dateTue 6 Jul 2021, 19:05 (5 years ago) parentfb93af7
2 files changed+39−12
benchmark/bench-report/BenchReport.hs+20−7 benchmark/bench-report/bin/bench-runner.sh+19−5
benchmark/bench-report/BenchReport.hs+20−7
@@ -28,6 +28,7 @@ data BenchType
2828data Options = Options
2929 { genGraphs :: Bool
3030 , sortByName :: Bool
31+ , useGauge :: Bool
3132 , benchType :: Maybe BenchType
3233 , fields :: [String]
3334 , diffStyle :: GroupStyle
@@ -35,7 +36,7 @@ data Options = Options
3536 } deriving Show
3637
3738defaultOptions :: Options
38−defaultOptions = Options False False Nothing ["time"] PercentDiff 0
39+defaultOptions = Options False False False Nothing ["time"] PercentDiff 0
3940
4041setGenGraphs :: Monad m => Bool -> StateT (a, Options) m ()
4142setGenGraphs val = do
@@ -47,6 +48,11 @@ setSortByName val = do
4748 (args, opts) <- get
4849 put (args, opts { sortByName = val })
4950
51+setUseGauge :: Monad m => Bool -> StateT (a, Options) m ()
52+setUseGauge val = do
53+ (args, opts) <- get
54+ put (args, opts { useGauge = val })
55+
5056setBenchType :: Monad m => BenchType -> StateT (a, Options) m ()
5157setBenchType val = do
5258 (args, opts) <- get
@@ -135,6 +141,7 @@ parseOptions = do
135141 case opt of
136142 "--graphs" -> setGenGraphs True
137143 "--sort-by-name" -> setSortByName True
144+ "--use-gauge" -> setUseGauge True
138145 "--benchmark" -> parseBench
139146 "--fields" -> parseFields
140147 "--diff-style" -> parseDiff
@@ -177,12 +184,18 @@ showComparisons Options{..} cfg inp out =
177184
178185 where
179186
180− dropComponent = dropWhile (== '/') . dropWhile (/= '/')
181−
182− classifyComparison b = Just
183− ( takeWhile (/= '/') b
184− , dropComponent b
185− )
187+ separator = if useGauge then '/' else '.'
188+ dropComponent = dropWhile (== separator) . dropWhile (/= separator)
189+
190+ classifyComparison b =
191+ let b1 =
192+ if useGauge
193+ then b
194+ else dropComponent b --- drop "All." at the beginning
195+ in Just
196+ ( takeWhile (/= separator) b1
197+ , dropComponent b1
198+ )
186199
187200------------------------------------------------------------------------------
188201-- text reports
benchmark/bench-report/bin/bench-runner.sh+19−5
@@ -178,15 +178,28 @@ bench_exec_one() {
178178 local BENCH_NAME1
179179 local BENCH_NAME2
180180 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 "/".
181184 if test "$USE_GAUGE" -eq 0
182185 then
183− # XXX this is a hack to make the "/" separated names used in the functions
184− # determining options based on benchmark name. For tasty-bench the benchmark
185− # names are separated by "." instead of "/".
186+ # Remove the prefix "All."
186187 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
187192 BENCH_NAME1=$(echo $BENCH_NAME0 | cut -f1 -d '/')
188− BENCH_NAME2=$(echo $BENCH_NAME0 | cut -f2- -d '/' | sed -e 's/\./\//g')
189− BENCH_NAME="$BENCH_NAME1/$BENCH_NAME2"
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
200+ BENCH_NAME2=/$(echo $BENCH_NAME0 | cut -f2- -d '/' | sed -e 's/\./\//g')
201+ fi
202+ BENCH_NAME="${BENCH_NAME1}${BENCH_NAME2}"
190203 else
191204 BENCH_NAME=$BENCH_NAME_ORIG
192205 fi
@@ -419,6 +432,7 @@ run_reports() {
419432 echo "Generating reports for ${i}..."
420433 $prog \
421434 --benchmark $i \
435+ $(test "$USE_GAUGE" = 1 && echo "--use-gauge") \
422436 $(test "$GRAPH" = 1 && echo "--graphs") \
423437 $(test "$SORT_BY_NAME" = 1 && echo "--sort-by-name") \
424438 $(test -n "$BENCH_DIFF_STYLE" && echo "--diff-style $BENCH_DIFF_STYLE") \