#21 Add debug flag

This commit is contained in:
Bodigrim 2021-10-11 00:22:49 +01:00
parent 3aada546fe
commit 91b5a175ed
4 changed files with 38 additions and 6 deletions

View File

@ -273,6 +273,14 @@ jobs:
- name: prepare for constraint sets
run: |
rm -f cabal.project.local
- name: constraint set no-tasty-debug
run: |
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='tasty-bench -tasty +debug' --dependencies-only -j2 all
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='tasty-bench -tasty +debug' all
- name: constraint set debug
run: |
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='tasty-bench +debug' --dependencies-only -j2 all
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='tasty-bench +debug' all
- name: constraint set no-tasty
run: |
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='tasty-bench -tasty' --dependencies-only -j2 all

View File

@ -651,6 +651,10 @@ import System.IO.Unsafe
import System.Mem
import Text.Printf
#ifdef DEBUG
import Debug.Trace
#endif
#ifdef MIN_VERSION_tasty
#if MIN_VERSION_containers(0,5,0)
import qualified Data.IntMap.Strict as IM
@ -914,12 +918,17 @@ measure n (Benchmarkable act) = do
act n
endTime <- fromInteger <$> getCPUTime
(endAllocs, endCopied, endMaxMemInUse) <- getAllocsAndCopied
pure $ Measurement
{ measTime = endTime - startTime
, measAllocs = endAllocs - startAllocs
, measCopied = endCopied - startCopied
, measMaxMem = max endMaxMemInUse startMaxMemInUse
}
let meas = Measurement
{ measTime = endTime - startTime
, measAllocs = endAllocs - startAllocs
, measCopied = endCopied - startCopied
, measMaxMem = max endMaxMemInUse startMaxMemInUse
}
#ifdef DEBUG
pure $ trace (show n ++ (if n == 1 then " iteration gives " else " iterations give ") ++ show meas) meas
#else
pure meas
#endif
measureUntil :: Bool -> Timeout -> RelStDev -> Benchmarkable -> IO Estimate
measureUntil _ _ (RelStDev targetRelStDev) b

View File

@ -1,2 +1,8 @@
constraint-set no-tasty
constraints: tasty-bench -tasty
constraint-set debug
constraints: tasty-bench +debug
constraint-set no-tasty-debug
constraints: tasty-bench -tasty +debug

View File

@ -37,6 +37,12 @@ flag tasty
When disabled, reduces API to functions independent of @tasty@: combinators
to construct @Benchmarkable@ and @measureCpuTime@.
flag debug
default: False
manual: True
description:
Emit ongoing diagnostic information for benchmarks.
library
exposed-modules: Test.Tasty.Bench
hs-source-dirs: .
@ -57,3 +63,6 @@ library
if impl(ghc < 7.8)
build-depends:
tagged >= 0.2
if flag(debug)
cpp-options: -DDEBUG