Skip to content

Commit 15e4f15

Browse files
committed
Run benchmark ingredients by hand so that defaultMain won’t overwrite locale to UTF-8. Arm runners don’t support outputting unicode but tasty-bench insists on doing so
1 parent 4059e25 commit 15e4f15

File tree

3 files changed

+43
-22
lines changed

3 files changed

+43
-22
lines changed

.github/workflows/haskell-ci.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ jobs:
115115
apt-get install -y curl ghc cabal-install libghc-tasty-quickcheck-dev libghc-tasty-hunit-dev g++
116116
run: |
117117
project_file="$(pwd)/cabal.project.test"
118+
118119
cabal update
120+
119121
cabal build --project-file "$project_file" --enable-tests --enable-benchmarks all
120-
cabal run --project-file "$project_file" test -- --quickcheck-tests=10000 --quickcheck-max-size=256
121-
cabal run --project-file "$project_file" bench -- --stdev 100 --timeout 600
122+
123+
LANG="C" cabal run --project-file "$project_file" test -- --quickcheck-tests=10000 --quickcheck-max-size=256 --ansi-tricks=false
124+
125+
LANG="C" cabal run --project-file "$project_file" bench -- --stdev 100 --timeout 600 --ansi-tricks=false

bench/BenchMain.hs

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,16 @@ import Data.Vector.Unboxed qualified as U
3838
import Data.Vector.Unboxed.Mutable qualified as UM
3939
import Data.Word
4040
import Foreign.C.Types
41+
import System.Exit
4142
import System.Random.Stateful
4243

43-
import Test.Tasty (localOption)
44+
import Test.Tasty
4445
import Test.Tasty.Bench
4546
import Test.Tasty.HUnit
47+
import Test.Tasty.Ingredients.ConsoleReporter (MinDurationToReport(MinDurationToReport))
48+
import Test.Tasty.Options
4649
import Test.Tasty.Patterns.Printer (printAwkExpr)
50+
import Test.Tasty.Runners
4751

4852
import ForeignSorting
4953

@@ -254,24 +258,37 @@ main = do
254258
evaluate $ rnf ysssNoDup
255259
evaluate $ rnf ysssDup
256260

257-
defaultMain $ map (localOption WallTime) $
258-
[ mkBenchesInt64 "Sorting fuzzy matching scores vector" (MkSolo fuzzyMatchScores)
259-
] ++
260-
[ bgroup "Int64" $
261-
[ mkBenchesInt64 ("Sorting " ++ show (length xss) ++ " random arrays of length " ++ T.unpack (formatNumber (P.length (head' xss))) ++ " with few duplicates") xss
262-
| xss <- xsssNoDup
263-
] ++
264-
[ mkBenchesInt64 ("Sorting " ++ show (length xss) ++ " random arrays of length " ++ T.unpack (formatNumber (P.length (head' xss))) ++ " with many duplicates") xss
265-
| xss <- xsssDup
266-
]
267-
, bgroup "(Double, Double, Int64)" $
268-
[ mkBenchesTriple ("Sorting " ++ show (length yss) ++ " random arrays of length " ++ T.unpack (formatNumber (U.length (head' yss))) ++ " with few duplicates") yss
269-
| yss <- ysssNoDup
270-
] ++
271-
[ mkBenchesTriple ("Sorting " ++ show (length yss) ++ " random arrays of length " ++ T.unpack (formatNumber (U.length (head' yss))) ++ " with many duplicates") yss
272-
| yss <- ysssDup
273-
]
274-
]
261+
let ingredients = benchIngredients
262+
263+
let benchmark = bgroup "All" $ map (localOption WallTime) $
264+
[ mkBenchesInt64 "Sorting fuzzy matching scores vector" (MkSolo fuzzyMatchScores)
265+
] ++
266+
[ bgroup "Int64" $
267+
[ mkBenchesInt64 ("Sorting " ++ show (length xss) ++ " random arrays of length " ++ T.unpack (formatNumber (P.length (head' xss))) ++ " with few duplicates") xss
268+
| xss <- xsssNoDup
269+
] ++
270+
[ mkBenchesInt64 ("Sorting " ++ show (length xss) ++ " random arrays of length " ++ T.unpack (formatNumber (P.length (head' xss))) ++ " with many duplicates") xss
271+
| xss <- xsssDup
272+
]
273+
, bgroup "(Double, Double, Int64)" $
274+
[ mkBenchesTriple ("Sorting " ++ show (length yss) ++ " random arrays of length " ++ T.unpack (formatNumber (U.length (head' yss))) ++ " with few duplicates") yss
275+
| yss <- ysssNoDup
276+
] ++
277+
[ mkBenchesTriple ("Sorting " ++ show (length yss) ++ " random arrays of length " ++ T.unpack (formatNumber (U.length (head' yss))) ++ " with many duplicates") yss
278+
| yss <- ysssDup
279+
]
280+
]
281+
282+
installSignalHandlers
283+
opts <- parseOptions ingredients benchmark
284+
let opts' = setOption (MinDurationToReport 1000000000000) $ setOption (NumThreads 1) opts
285+
286+
case tryIngredients ingredients opts' benchmark of
287+
Nothing -> die
288+
"No ingredients agreed to run. Something is wrong either with your ingredient set or the options."
289+
Just act -> do
290+
ok <- act
291+
if ok then exitSuccess else exitFailure
275292

276293
head' :: [a] -> a
277294
head' (x:_) = x

vector-quicksort.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ benchmark bench
266266
, deepseq
267267
, random
268268
, stm
269-
, tasty
269+
, tasty >= 1.5
270270
, tasty-bench >= 0.3.2
271271
, tasty-hunit
272272
, text

0 commit comments

Comments
 (0)