Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions src/catch2/benchmark/detail/catch_stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,12 @@ namespace Catch {
sum_cubes += cube;
}

double accel = sum_cubes / ( 6 * std::pow( sum_squares, 1.5 ) );
// With no spread in the jackknife estimates there is nothing
// to estimate the acceleration from (and 0 / 0 would be NaN)
double accel =
sum_squares > 0
? sum_cubes / ( 6 * std::pow( sum_squares, 1.5 ) )
: 0.;
long n = static_cast<long>( resample.size() );
double prob_n = static_cast<double>(
std::count_if( resample.begin(),
Expand All @@ -329,9 +334,16 @@ namespace Catch {
double bias = normal_quantile( prob_n );
double z1 = normal_quantile( ( 1. - confidence_level ) / 2. );

auto cumn = [n]( double x ) -> long {
return std::lround( normal_cdf( x ) *
static_cast<double>( n ) );
// a1 and a2 can still end up NaN or infinite for degenerate
// inputs, so make sure the index always stays inside resample
auto cumn = [n]( double x, long fallback ) -> size_t {
if ( std::isnan( x ) ) {
return static_cast<size_t>( fallback );
}
long idx = std::lround( normal_cdf( x ) *
static_cast<double>( n ) );
return static_cast<size_t>(
(std::min)( (std::max)( idx, 0l ), n - 1 ) );
};
auto a = [bias, accel]( double b ) {
return bias + b / ( 1. - accel * b );
Expand All @@ -340,9 +352,8 @@ namespace Catch {
double b2 = bias - z1;
double a1 = a( b1 );
double a2 = a( b2 );
auto lo = static_cast<size_t>( (std::max)( cumn( a1 ), 0l ) );
auto hi =
static_cast<size_t>( (std::min)( cumn( a2 ), n - 1 ) );
auto lo = cumn( a1, 0 );
auto hi = cumn( a2, n - 1 );

return { point, resample[lo], resample[hi], confidence_level };
}
Expand Down
1 change: 1 addition & 0 deletions tests/SelfTest/Baselines/automake.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ Message from section two
:test-result: PASS array<int, N> -> toString
:test-result: PASS benchmark function call
:test-result: PASS boolean member
:test-result: PASS bootstrap keeps the interval inside the resample
:test-result: PASS cat generator
:test-result: PASS checkedElse
:test-result: FAIL checkedElse, failing
Expand Down
1 change: 1 addition & 0 deletions tests/SelfTest/Baselines/automake.sw.multi.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@
:test-result: PASS array<int, N> -> toString
:test-result: PASS benchmark function call
:test-result: PASS boolean member
:test-result: PASS bootstrap keeps the interval inside the resample
:test-result: PASS cat generator
:test-result: PASS checkedElse
:test-result: FAIL checkedElse, failing
Expand Down
10 changes: 8 additions & 2 deletions tests/SelfTest/Baselines/compact.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2595,6 +2595,12 @@ InternalBenchmark.tests.cpp:<line number>: passed: model.started == 0 for: 0 ==
InternalBenchmark.tests.cpp:<line number>: passed: model.finished == 0 for: 0 == 0
InternalBenchmark.tests.cpp:<line number>: passed: called == 1 for: 1 == 1
Tricky.tests.cpp:<line number>: passed: obj.prop != 0 for: 0x<hex digits> != 0
InternalBenchmark.tests.cpp:<line number>: passed: e.point == 23 for: 23.0 == 23
InternalBenchmark.tests.cpp:<line number>: passed: e.lower_bound == 22 for: 22.0 == 22
InternalBenchmark.tests.cpp:<line number>: passed: e.upper_bound == 24 for: 24.0 == 24
InternalBenchmark.tests.cpp:<line number>: passed: e.point == 4 for: 4.0 == 4
InternalBenchmark.tests.cpp:<line number>: passed: e.lower_bound == 0.5 for: 0.5 == 0.5
InternalBenchmark.tests.cpp:<line number>: passed: e.upper_bound == 2 for: 2.0 == 2
Generators.tests.cpp:<line number>: passed: input < 3 for: 0 < 3
Generators.tests.cpp:<line number>: passed: input < 3 for: 1 < 3
Generators.tests.cpp:<line number>: passed: input < 3 for: 2 < 3
Expand Down Expand Up @@ -3030,7 +3036,7 @@ InternalBenchmark.tests.cpp:<line number>: passed: med == 18. for: 18.0 == 18.0
InternalBenchmark.tests.cpp:<line number>: passed: q3 == 23. for: 23.0 == 23.0
Misc.tests.cpp:<line number>: passed:
Misc.tests.cpp:<line number>: passed:
test cases: 455 | 335 passed | 96 failed | 6 skipped | 18 failed as expected
assertions: 2438 | 2237 passed | 158 failed | 43 failed as expected
test cases: 456 | 336 passed | 96 failed | 6 skipped | 18 failed as expected
assertions: 2444 | 2243 passed | 158 failed | 43 failed as expected


10 changes: 8 additions & 2 deletions tests/SelfTest/Baselines/compact.sw.multi.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2588,6 +2588,12 @@ InternalBenchmark.tests.cpp:<line number>: passed: model.started == 0 for: 0 ==
InternalBenchmark.tests.cpp:<line number>: passed: model.finished == 0 for: 0 == 0
InternalBenchmark.tests.cpp:<line number>: passed: called == 1 for: 1 == 1
Tricky.tests.cpp:<line number>: passed: obj.prop != 0 for: 0x<hex digits> != 0
InternalBenchmark.tests.cpp:<line number>: passed: e.point == 23 for: 23.0 == 23
InternalBenchmark.tests.cpp:<line number>: passed: e.lower_bound == 22 for: 22.0 == 22
InternalBenchmark.tests.cpp:<line number>: passed: e.upper_bound == 24 for: 24.0 == 24
InternalBenchmark.tests.cpp:<line number>: passed: e.point == 4 for: 4.0 == 4
InternalBenchmark.tests.cpp:<line number>: passed: e.lower_bound == 0.5 for: 0.5 == 0.5
InternalBenchmark.tests.cpp:<line number>: passed: e.upper_bound == 2 for: 2.0 == 2
Generators.tests.cpp:<line number>: passed: input < 3 for: 0 < 3
Generators.tests.cpp:<line number>: passed: input < 3 for: 1 < 3
Generators.tests.cpp:<line number>: passed: input < 3 for: 2 < 3
Expand Down Expand Up @@ -3019,7 +3025,7 @@ InternalBenchmark.tests.cpp:<line number>: passed: med == 18. for: 18.0 == 18.0
InternalBenchmark.tests.cpp:<line number>: passed: q3 == 23. for: 23.0 == 23.0
Misc.tests.cpp:<line number>: passed:
Misc.tests.cpp:<line number>: passed:
test cases: 455 | 335 passed | 96 failed | 6 skipped | 18 failed as expected
assertions: 2438 | 2237 passed | 158 failed | 43 failed as expected
test cases: 456 | 336 passed | 96 failed | 6 skipped | 18 failed as expected
assertions: 2444 | 2243 passed | 158 failed | 43 failed as expected


4 changes: 2 additions & 2 deletions tests/SelfTest/Baselines/console.std.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1743,6 +1743,6 @@ due to unexpected exception with message:
Why would you throw a std::string?

===============================================================================
test cases: 455 | 353 passed | 76 failed | 7 skipped | 19 failed as expected
assertions: 2416 | 2237 passed | 136 failed | 43 failed as expected
test cases: 456 | 354 passed | 76 failed | 7 skipped | 19 failed as expected
assertions: 2422 | 2243 passed | 136 failed | 43 failed as expected

48 changes: 46 additions & 2 deletions tests/SelfTest/Baselines/console.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17198,6 +17198,50 @@ Tricky.tests.cpp:<line number>: PASSED:
with expansion:
0x<hex digits> != 0

-------------------------------------------------------------------------------
bootstrap keeps the interval inside the resample
no spread in the jackknife estimates
-------------------------------------------------------------------------------
InternalBenchmark.tests.cpp:<line number>
...............................................................................

InternalBenchmark.tests.cpp:<line number>: PASSED:
CHECK( e.point == 23 )
with expansion:
23.0 == 23

InternalBenchmark.tests.cpp:<line number>: PASSED:
CHECK( e.lower_bound == 22 )
with expansion:
22.0 == 22

InternalBenchmark.tests.cpp:<line number>: PASSED:
CHECK( e.upper_bound == 24 )
with expansion:
24.0 == 24

-------------------------------------------------------------------------------
bootstrap keeps the interval inside the resample
every resampled estimate below the point estimate
-------------------------------------------------------------------------------
InternalBenchmark.tests.cpp:<line number>
...............................................................................

InternalBenchmark.tests.cpp:<line number>: PASSED:
CHECK( e.point == 4 )
with expansion:
4.0 == 4

InternalBenchmark.tests.cpp:<line number>: PASSED:
CHECK( e.lower_bound == 0.5 )
with expansion:
0.5 == 0.5

InternalBenchmark.tests.cpp:<line number>: PASSED:
CHECK( e.upper_bound == 2 )
with expansion:
2.0 == 2

-------------------------------------------------------------------------------
cat generator
Simple usage
Expand Down Expand Up @@ -20327,6 +20371,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED:

===============================================================================
test cases: 455 | 335 passed | 96 failed | 6 skipped | 18 failed as expected
assertions: 2438 | 2237 passed | 158 failed | 43 failed as expected
test cases: 456 | 336 passed | 96 failed | 6 skipped | 18 failed as expected
assertions: 2444 | 2243 passed | 158 failed | 43 failed as expected

48 changes: 46 additions & 2 deletions tests/SelfTest/Baselines/console.sw.multi.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17191,6 +17191,50 @@ Tricky.tests.cpp:<line number>: PASSED:
with expansion:
0x<hex digits> != 0

-------------------------------------------------------------------------------
bootstrap keeps the interval inside the resample
no spread in the jackknife estimates
-------------------------------------------------------------------------------
InternalBenchmark.tests.cpp:<line number>
...............................................................................

InternalBenchmark.tests.cpp:<line number>: PASSED:
CHECK( e.point == 23 )
with expansion:
23.0 == 23

InternalBenchmark.tests.cpp:<line number>: PASSED:
CHECK( e.lower_bound == 22 )
with expansion:
22.0 == 22

InternalBenchmark.tests.cpp:<line number>: PASSED:
CHECK( e.upper_bound == 24 )
with expansion:
24.0 == 24

-------------------------------------------------------------------------------
bootstrap keeps the interval inside the resample
every resampled estimate below the point estimate
-------------------------------------------------------------------------------
InternalBenchmark.tests.cpp:<line number>
...............................................................................

InternalBenchmark.tests.cpp:<line number>: PASSED:
CHECK( e.point == 4 )
with expansion:
4.0 == 4

InternalBenchmark.tests.cpp:<line number>: PASSED:
CHECK( e.lower_bound == 0.5 )
with expansion:
0.5 == 0.5

InternalBenchmark.tests.cpp:<line number>: PASSED:
CHECK( e.upper_bound == 2 )
with expansion:
2.0 == 2

-------------------------------------------------------------------------------
cat generator
Simple usage
Expand Down Expand Up @@ -20316,6 +20360,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED:

===============================================================================
test cases: 455 | 335 passed | 96 failed | 6 skipped | 18 failed as expected
assertions: 2438 | 2237 passed | 158 failed | 43 failed as expected
test cases: 456 | 336 passed | 96 failed | 6 skipped | 18 failed as expected
assertions: 2444 | 2243 passed | 158 failed | 43 failed as expected

5 changes: 4 additions & 1 deletion tests/SelfTest/Baselines/junit.sw.approved.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact
>
<testsuite name="<exe-name>" errors="17" failures="141" skipped="12" tests="2450" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testsuite name="<exe-name>" errors="17" failures="141" skipped="12" tests="2456" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="random-seed" value="1"/>
<property name="filters" value="&quot;*&quot; ~[!nonportable] ~[!benchmark] ~[approvals]"/>
Expand Down Expand Up @@ -1570,6 +1570,9 @@ at Skip.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="benchmark function call/without chronometer" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="benchmark function call/with chronometer" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="boolean member" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="bootstrap keeps the interval inside the resample" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="bootstrap keeps the interval inside the resample/no spread in the jackknife estimates" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="bootstrap keeps the interval inside the resample/every resampled estimate below the point estimate" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="cat generator" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="cat generator/Simple usage" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="cat generator/Used in map" time="{duration}" status="run"/>
Expand Down
5 changes: 4 additions & 1 deletion tests/SelfTest/Baselines/junit.sw.multi.approved.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="<exe-name>" errors="17" failures="141" skipped="12" tests="2450" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testsuite name="<exe-name>" errors="17" failures="141" skipped="12" tests="2456" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="random-seed" value="1"/>
<property name="filters" value="&quot;*&quot; ~[!nonportable] ~[!benchmark] ~[approvals]"/>
Expand Down Expand Up @@ -1569,6 +1569,9 @@ at Skip.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="benchmark function call/without chronometer" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="benchmark function call/with chronometer" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="boolean member" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="bootstrap keeps the interval inside the resample" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="bootstrap keeps the interval inside the resample/no spread in the jackknife estimates" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="bootstrap keeps the interval inside the resample/every resampled estimate below the point estimate" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="cat generator" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="cat generator/Simple usage" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="cat generator/Used in map" time="{duration}" status="run"/>
Expand Down
3 changes: 3 additions & 0 deletions tests/SelfTest/Baselines/sonarqube.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ at AssertionHandler.tests.cpp:<line number>
<testCase name="benchmark function call" duration="{duration}"/>
<testCase name="benchmark function call/without chronometer" duration="{duration}"/>
<testCase name="benchmark function call/with chronometer" duration="{duration}"/>
<testCase name="bootstrap keeps the interval inside the resample" duration="{duration}"/>
<testCase name="bootstrap keeps the interval inside the resample/no spread in the jackknife estimates" duration="{duration}"/>
<testCase name="bootstrap keeps the interval inside the resample/every resampled estimate below the point estimate" duration="{duration}"/>
<testCase name="classify_outliers" duration="{duration}"/>
<testCase name="classify_outliers/none" duration="{duration}"/>
<testCase name="classify_outliers/low severe" duration="{duration}"/>
Expand Down
3 changes: 3 additions & 0 deletions tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ at AssertionHandler.tests.cpp:<line number>
<testCase name="benchmark function call" duration="{duration}"/>
<testCase name="benchmark function call/without chronometer" duration="{duration}"/>
<testCase name="benchmark function call/with chronometer" duration="{duration}"/>
<testCase name="bootstrap keeps the interval inside the resample" duration="{duration}"/>
<testCase name="bootstrap keeps the interval inside the resample/no spread in the jackknife estimates" duration="{duration}"/>
<testCase name="bootstrap keeps the interval inside the resample/every resampled estimate below the point estimate" duration="{duration}"/>
<testCase name="classify_outliers" duration="{duration}"/>
<testCase name="classify_outliers/none" duration="{duration}"/>
<testCase name="classify_outliers/low severe" duration="{duration}"/>
Expand Down
14 changes: 13 additions & 1 deletion tests/SelfTest/Baselines/tap.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4141,6 +4141,18 @@ ok {test-number} - model.finished == 0 for: 0 == 0
ok {test-number} - called == 1 for: 1 == 1
# boolean member
ok {test-number} - obj.prop != 0 for: 0x<hex digits> != 0
# bootstrap keeps the interval inside the resample
ok {test-number} - e.point == 23 for: 23.0 == 23
# bootstrap keeps the interval inside the resample
ok {test-number} - e.lower_bound == 22 for: 22.0 == 22
# bootstrap keeps the interval inside the resample
ok {test-number} - e.upper_bound == 24 for: 24.0 == 24
# bootstrap keeps the interval inside the resample
ok {test-number} - e.point == 4 for: 4.0 == 4
# bootstrap keeps the interval inside the resample
ok {test-number} - e.lower_bound == 0.5 for: 0.5 == 0.5
# bootstrap keeps the interval inside the resample
ok {test-number} - e.upper_bound == 2 for: 2.0 == 2
# cat generator
ok {test-number} - input < 3 for: 0 < 3
# cat generator
Expand Down Expand Up @@ -4895,5 +4907,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
ok {test-number} -
# xmlentitycheck
ok {test-number} -
1..2450
1..2456

14 changes: 13 additions & 1 deletion tests/SelfTest/Baselines/tap.sw.multi.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4134,6 +4134,18 @@ ok {test-number} - model.finished == 0 for: 0 == 0
ok {test-number} - called == 1 for: 1 == 1
# boolean member
ok {test-number} - obj.prop != 0 for: 0x<hex digits> != 0
# bootstrap keeps the interval inside the resample
ok {test-number} - e.point == 23 for: 23.0 == 23
# bootstrap keeps the interval inside the resample
ok {test-number} - e.lower_bound == 22 for: 22.0 == 22
# bootstrap keeps the interval inside the resample
ok {test-number} - e.upper_bound == 24 for: 24.0 == 24
# bootstrap keeps the interval inside the resample
ok {test-number} - e.point == 4 for: 4.0 == 4
# bootstrap keeps the interval inside the resample
ok {test-number} - e.lower_bound == 0.5 for: 0.5 == 0.5
# bootstrap keeps the interval inside the resample
ok {test-number} - e.upper_bound == 2 for: 2.0 == 2
# cat generator
ok {test-number} - input < 3 for: 0 < 3
# cat generator
Expand Down Expand Up @@ -4884,5 +4896,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
ok {test-number} -
# xmlentitycheck
ok {test-number} -
1..2450
1..2456

2 changes: 2 additions & 0 deletions tests/SelfTest/Baselines/teamcity.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,8 @@
##teamcity[testFinished name='benchmark function call' duration="{duration}"]
##teamcity[testStarted name='boolean member']
##teamcity[testFinished name='boolean member' duration="{duration}"]
##teamcity[testStarted name='bootstrap keeps the interval inside the resample']
##teamcity[testFinished name='bootstrap keeps the interval inside the resample' duration="{duration}"]
##teamcity[testStarted name='cat generator']
##teamcity[testFinished name='cat generator' duration="{duration}"]
##teamcity[testStarted name='checkedElse']
Expand Down
2 changes: 2 additions & 0 deletions tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,8 @@
##teamcity[testFinished name='benchmark function call' duration="{duration}"]
##teamcity[testStarted name='boolean member']
##teamcity[testFinished name='boolean member' duration="{duration}"]
##teamcity[testStarted name='bootstrap keeps the interval inside the resample']
##teamcity[testFinished name='bootstrap keeps the interval inside the resample' duration="{duration}"]
##teamcity[testStarted name='cat generator']
##teamcity[testFinished name='cat generator' duration="{duration}"]
##teamcity[testStarted name='checkedElse']
Expand Down
Loading
Loading