From a93558e16827f4f8af33155590dca715d9bdf080 Mon Sep 17 00:00:00 2001 From: kwxm Date: Sat, 4 May 2024 13:01:47 +0100 Subject: [PATCH 1/2] Remove annoying error message --- .../cost-model/budgeting-bench/Benchmarks/Strings.hs | 6 ++---- .../cost-model/budgeting-bench/CriterionExtensions.hs | 6 ++++-- plutus-core/cost-model/budgeting-bench/Main.hs | 5 ----- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/plutus-core/cost-model/budgeting-bench/Benchmarks/Strings.hs b/plutus-core/cost-model/budgeting-bench/Benchmarks/Strings.hs index 8025447052e..93c0b5a8d8f 100644 --- a/plutus-core/cost-model/budgeting-bench/Benchmarks/Strings.hs +++ b/plutus-core/cost-model/budgeting-bench/Benchmarks/Strings.hs @@ -147,11 +147,9 @@ benchTwoTextStrings name = s2 = makeSizedTextStrings seedB twoArgumentSizes in createTwoTermBuiltinBench name [] s1 s2 - -- Benchmark times for a function applied to equal arguments. This is used for --- benchmarking EqualsString on the diagonal. --- Copy the bytestring here, because otherwise it'll be exactly the same and --- the equality will short-circuit. +-- benchmarking EqualsString on the diagonal. Copy the string here, because +-- otherwise it'll be exactly the same and the equality will short-circuit. benchSameTwoTextStrings :: DefaultFun -> Benchmark benchSameTwoTextStrings name = createTwoTermBuiltinBenchElementwise name [] inputs (fmap T.copy inputs) diff --git a/plutus-core/cost-model/budgeting-bench/CriterionExtensions.hs b/plutus-core/cost-model/budgeting-bench/CriterionExtensions.hs index ba349446ec5..d22256b4967 100644 --- a/plutus-core/cost-model/budgeting-bench/CriterionExtensions.hs +++ b/plutus-core/cost-model/budgeting-bench/CriterionExtensions.hs @@ -93,11 +93,13 @@ criterionMainWith phase defCfg bs = runAndAnalyse shouldRun bsgroup where bsgroup = BenchGroup "" bs +-- Select the benchmarks to be run. If a pattern is specified on the command +-- line then only the matching benchmarks will be run. If there are no matching +-- benchmarks then the command will stil succeed (with no error or warning), but +-- nothing will be benchmarked. selectBenches :: MatchType -> [String] -> Benchmark -> IO (String -> Bool) selectBenches matchType benches bsgroup = do toRun <- either parseError return . makeMatcher matchType $ benches - unless (null benches || any toRun (benchNames bsgroup)) $ - parseError "none of the specified names matches a benchmark" return toRun parseError :: String -> IO a diff --git a/plutus-core/cost-model/budgeting-bench/Main.hs b/plutus-core/cost-model/budgeting-bench/Main.hs index 7571b534e2a..353232d1a21 100644 --- a/plutus-core/cost-model/budgeting-bench/Main.hs +++ b/plutus-core/cost-model/budgeting-bench/Main.hs @@ -61,11 +61,6 @@ main = do {- Run the nop benchmarks with a large time limit (30 seconds) in an attempt to get accurate results. -} - -- FIXME: this doesn't quite work. If you specify a benchmark name on the - -- command line and it's in the first group then it'll run but you'll get an - -- error when the argument gets passed to the nop benchmarks below (but the - -- data will still be generated and saved in benching.csv). - criterionMainWith Continue (defaultConfig { C.timeLimit = 30 }) $ From 0d542269d8c2f57370027ba8f337b559199dea43 Mon Sep 17 00:00:00 2001 From: kwxm Date: Sat, 4 May 2024 13:20:10 +0100 Subject: [PATCH 2/2] Forgot to remove unused imports etc. --- .../cost-model/budgeting-bench/CriterionExtensions.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plutus-core/cost-model/budgeting-bench/CriterionExtensions.hs b/plutus-core/cost-model/budgeting-bench/CriterionExtensions.hs index d22256b4967..d3b89093e98 100644 --- a/plutus-core/cost-model/budgeting-bench/CriterionExtensions.hs +++ b/plutus-core/cost-model/budgeting-bench/CriterionExtensions.hs @@ -2,7 +2,6 @@ module CriterionExtensions (criterionMainWith, BenchmarkingPhase(..)) where -import Control.Monad (unless) import Control.Monad.Trans (liftIO) import Criterion.Internal (runAndAnalyse, runFixedIters) import Criterion.IO.Printf (printError, writeCsv) @@ -83,12 +82,12 @@ criterionMainWith phase defCfg bs = RunIters cfg iters matchType benches -> withConfig cfg $ do () <- initCsvFile phase cfg - shouldRun <- liftIO $ selectBenches matchType benches bsgroup + shouldRun <- liftIO $ selectBenches matchType benches runFixedIters iters shouldRun bsgroup Run cfg matchType benches -> withConfig cfg $ do () <- initCsvFile phase cfg - shouldRun <- liftIO $ selectBenches matchType benches bsgroup + shouldRun <- liftIO $ selectBenches matchType benches liftIO initializeTime runAndAnalyse shouldRun bsgroup where bsgroup = BenchGroup "" bs @@ -97,8 +96,8 @@ criterionMainWith phase defCfg bs = -- line then only the matching benchmarks will be run. If there are no matching -- benchmarks then the command will stil succeed (with no error or warning), but -- nothing will be benchmarked. -selectBenches :: MatchType -> [String] -> Benchmark -> IO (String -> Bool) -selectBenches matchType benches bsgroup = do +selectBenches :: MatchType -> [String] -> IO (String -> Bool) +selectBenches matchType benches = do toRun <- either parseError return . makeMatcher matchType $ benches return toRun