ut
nanobench
Our great sponsors
ut | nanobench | |
---|---|---|
10 | 13 | |
1,197 | 1,307 | |
1.8% | - | |
7.0 | 5.0 | |
about 1 month ago | 8 months ago | |
C++ | C++ | |
Boost Software License 1.0 | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
ut
-
[C++20][safety] static_assert is all you need (no leaks, no UB)
I don't think stepping through static_assert is a thing? Curious if it is, though. Since constexpr is either run-time or compile-time and static_assert is not a poor man's debugging facility could be to -Dstatic_assert(...) assert(__VA_ARGS__) and gdb the code. Alternatively, a more refined solution would be to use an UT framework (for example https://github.com/boost-ext/ut) which helps with that. IMHO, TDD can also limit the requirement of stepping into the code and with gurantees that the code is memory safe and UB safe there is less need for sanitizers and valgrind etc. depending on the coverage.
-
snatch -- A lightweight C++20 testing framework
It was not easy, I had to modify Boost UT to get it to run my tests. It doesn't support type-parametrized tests when the type parameter is non-copiable, which was the case for me. This is a symptom of a larger issue, which is that it relies on std::apply and std::tuple to generate the type-parametrized tests, which in turns requires instantiating the tuple and the contained objects (even though these instances aren't actually used; eh). That's a no go for me, since I need to carefully monitor when instance are created, and this was throwing off my test code. I had to effectively disable these checks to get it to run without failures. Then there was a similar issue with expect(), which doesn't work if part of the expression is non-copiable. I reported these issues to them.
-
[C++20] New way of meta-programming?
https://github.com/boost-ext/ut (for better user interface when defining tests without macros)
-
Getting started with Boost in 2022
https://github.com/boost-ext/ut from Kris Jusiak is worth checking
- How to unit test
-
Calculate Your Code Performance
C++: C++ has quite a number of benchmarking libraries some of the recent ones involving C++ 20's flexibility. The most notable being Google Bench and UT. C does not have many specific benchmarking libraries, but you can easily integrate C code with C++ benchmarking libraries in order to test the performance of your C code.
-
Benchmarking Code
UT
-
Another C++ unit testing framework without macros
In Boost.UT there is a number of different styles to add a parametrized test case. All of them are pretty cryptic bue to heavy isage of oeverloaded operators of custom "non-public" classes. Except for the for-loop method, in all other methods the list of parameter values goes after the test procedure definition. I find this inconvenient, as I want to see list of parameter value next to the test name. This is what I used to from the times I was coding a lot of unit tests in C#.
nanobench
-
The issue of unit tests and performance measurements (Benchmark)
An alternative is tracking the number of instructions a test executes: https://github.com/martinus/nanobench
-
how do you properly benchmark?
Nano bench is a great library with low overhead. https://github.com/martinus/nanobench
-
Much Faster than std::string, fmt::format, std::to_chars, std::time and more?
I've done a relatively simple test of taking random doubles (between 0 and 1), converting them to a C string via std::to_chars and then converting that C string back to a double via std::from_chars vs his xeerx::chars_to and got the following results on my machine via nanobench:
-
Can you give an example of well-designed C++ code, and explain why you think it is so?
I like https://nanobench.ankerl.com/
-
Best accurate way to measure/compare elapsed time in C++
Of course, the best way to benchmark is nanobench: https://nanobench.ankerl.com/
-
The 23 year-old C++ developers with three job offers over $500k
I've created robin-hood-hashing and nanobench, and recently made some contributions to Bitcoin and doxygen
-
I don’t know which container to use (and at this point I’m too afraid to ask)
Right. Regex runtime construction is known to be slow, so ideally the state machinery construction is built at compile time (boost.xpressive, ctre). Also, boost.regex is faster than most of the std implementations if compile time isn’t possible. And if that’s no good rewrite without regex. Since it sounds like it’s all encapsulated at least it would be easy to measure the options. These days I use this one to compare https://nanobench.ankerl.com/
-
I'm writing a microbenchmarking library called "precision" without any macros. What do you guys think of the API?
You can check the API of nanobench which also doesn't use macros, as far as I have used it.
-
C++20 std::format is 2x slower than std::fstream?
I've tried again with your latest changes and decided to use https://github.com/martinus/nanobench for a better benchmark and got the following output:
- Nanobench: Fast, Accurate, Single-Header Microbenchmarking Functionality For C++
What are some alternatives?
Boost.Test - The reference C++ unit testing framework (TDD, xUnit, C++03/11/14/17)
benchmark - A microbenchmark support library
Catch - A modern, C++-native, test framework for unit-tests, TDD and BDD - using C++14, C++17 and later (C++11 support is in v2.x branch, and C++03 on the Catch1.x branch)
fast_io - C++20 Concepts IO library which is 10x faster than stdio and iostream
FakeIt - C++ mocking made easy. A simple yet very expressive, headers only library for c++ mocking.
robin-hood-hashing - Fast & memory efficient hashtable based on robin hood hashing for C++11/14/17/20
doctest - The fastest feature-rich C++11/14/17/20/23 single-header testing framework
curl4cpp - Single header cURL wrapper for C++ around libcURL
test - A library for writing unit tests in Dart.
bench-rest - bench-rest - benchmark REST (HTTP/HTTPS) API's. node.js client module for easy load testing / benchmarking REST API's using a simple structure/DSL can create REST flows with setup and teardown and returns (measured) metrics.
KmTest - Kernel-mode C++ unit testing framework in BDD-style
dtoa-benchmark - C++ double-to-string conversion benchmark