mirror of
https://github.com/Bodigrim/tasty-bench.git
synced 2024-09-11 16:56:14 +03:00
#21 Add debug flag
This commit is contained in:
parent
3aada546fe
commit
91b5a175ed
8
.github/workflows/haskell-ci.yml
vendored
8
.github/workflows/haskell-ci.yml
vendored
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user