Comments (4)
You can't do this with Catch2, because the benchmark will always run the function at least twice. Once for the sample you ask for, but before that happens it will run at least once for the warmup. --benchmark-warmup-time
sets the minimal time spent in warmup, but even setting it to 0 does not skip it.
--benchmark-resamples 1
does not do anything when combined with --benchmark-no-analysis
, as these change how (and whether) the bootstrapping analysis from the taken samples happen.
from catch2.
And wouldn't it be relevant to specifically test if --benchmark-warmup-time 0
was set, and if yes, simply skip the warmup?
from catch2.
That could be done, but that is a very specific, and frankly weird, use case. Catch2 primarily targets microbenchmarking and attempts to provide high quality statistical output. Doing only one sample, especially without warm up, can't provide that, and the only advantage of using BENCHMARK
over auto t1 = std::chrono::steady_clock::now(); ... ; auto t2 =
is that the output will go through the reporter.
Furthermore, if this is a function that can only be called once in program's lifetime (e.g. libfoo_init
), trying to call it inside a benchmark/test is generally a bad idea, as it makes it easy to skip calling it or call it multiple times through test/benchmark selection. If, on the other hand, you have a function that can only be called once per set-up (e.g. member function on a class that steals internal state with a check that it was not called multiple times), you should instead provide sufficient setup through the advanced benchmarking facilities (this is also used e.g. for benchmarks of destructive algorithms).
from catch2.
Without entering the details of my use case, it consists on few steps, running in a given order, each of them being internally protected against replay attacks. And I want to benchmark each of the steps, and the benchmark results to be included in the report (thus go through the reporter).
If there is a way to do so (maybe using BENCHMARK_ADVANCED
, but I don't see how), please let me know.
But most important, independently of my use case, I would normally expect --benchmark-warmup-time 0
to skip the warmup. Or maybe accept a negative number if, internally, the code does something like
while (current_warmup_time <= max_warmup_time) {
// do something
}
so that --benchmark-warmup-time -1
would actually skip it.
from catch2.
Related Issues (20)
- When the same SECTION is encountered multiple times in one cycle, catch crashes on assert HOT 2
- error: size of array ‘altStackMem’ is not an integral constant-expression HOT 1
- riscv: build failure due to Werror=cast-align HOT 2
- Generator results into a fatal error in 2.13.9 (newest not tested)
- Supplying own command line options by following the documentation results in UB (?) HOT 1
- I place a benchmark inside a TEST_CASE() and I don't see the results HOT 2
- Wunused-variable in (DYNAMIC_)SECTION when CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT is enabled HOT 1
- tsan reports data race on multithread std::cout HOT 3
- XML Reporter doesn't output stderr / stdin when there is a segfault HOT 3
- unnecessary double promotion generate warning.
- Support multiple reporters for `catch_discover_tests` HOT 1
- Integrate Generators into reporters and CLI HOT 2
- Extend support for randomness generation in tests
- Finish JSON reporter & use it for more reliable CMake/CTest integration
- Update documentation for v3 HOT 2
- Provide Catch2's StringMaker specialization behind extra level of indirection
- Handle ANSI escape sequences during text wrapping
- Bring back Single-Header capability HOT 2
- AddressSanitizer reports container overflow during benchmarking HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from catch2.