@@ -38,12 +38,16 @@ import Data.Vector.Unboxed qualified as U
3838import Data.Vector.Unboxed.Mutable qualified as UM
3939import Data.Word
4040import Foreign.C.Types
41+ import System.Exit
4142import System.Random.Stateful
4243
43- import Test.Tasty ( localOption )
44+ import Test.Tasty
4445import Test.Tasty.Bench
4546import Test.Tasty.HUnit
47+ import Test.Tasty.Ingredients.ConsoleReporter (MinDurationToReport (MinDurationToReport ))
48+ import Test.Tasty.Options
4649import Test.Tasty.Patterns.Printer (printAwkExpr )
50+ import Test.Tasty.Runners
4751
4852import 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
276293head' :: [a ] -> a
277294head' (x: _) = x
0 commit comments