chronoxor / cppbenchmark Goto Github PK
View Code? Open in Web Editor NEWPerformance benchmark framework for C++ with nanoseconds measure precision
License: MIT License
Performance benchmark framework for C++ with nanoseconds measure precision
License: MIT License
In README.md
How to build?
Linux
cd build
./unix.sh
don't have build directory and don't have unix.sh in the workspace.
I am browsing the examples and putting things together, and noticed, that the sort example does not really make sense.
Each sort class inheriting from the SortFixture calls Initialize at the beginning of an attempt, which populates the items, but then in each Run called during an attempt, the items are not changed. So the first Run sorts the items and then every subsequent run has the items already sorted.
Hello,
I managed to build the library on my machine with the build/vst.bat script, seems fine.
I tried to link with the library in my C++ console application project, I added include directories - CppBenchmark/Include and lib directories CppBenchmark/bin and added cppbenchmark.lib to my linker settings.
Then to my main.cpp file i just copied some of your examples - the random.cpp one, but when I compile, I get linker errors. Some unersolved symbols in file cppbenchmark.lib(launcher_console.obj) - optparse::OptionParser::print_help(), optparse::OptionParser::error(),optparse::OptionParser::parse_args() and others.
And in file cppbenchmark.lib(phase_metrics.obj) - unresolved symbols hdr_init, hdr_close, hdr_record_values, hrd_min, etc...
Do I need to link other libraries to my project as well?
I am on Win 10, VS 2019
Thanks
I build CppBenchmark library and put libcppbenchmark.a into /usr/lib/, then I try to compile serialize.cpp with flag -lcppbenchmark under FastBinaryEncoding/performance/, but it turns out an error like this:
serialize.cpp:5:10: fatal error: benchmark/cppbenchmark.h: No such file or directory
5 | #include "benchmark/cppbenchmark.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
What should I do?
When using std::aligned_storage, you must explicitly call constructor and destructors on the "reinterpreted_cast"'d object (with placement new, and explicit output->~T() call).
In all case, std::aligned_storage is not required in this file, since the compiler will ensure that the structure is correctly aligned anyway.
By default, unless you pragma pack your structure (which is not the case here), the compiler will ensure the structure is aligned with respect to its largest field's alignment requirement, and that's exactly what you get with the std::aligned_storage code that's written.
I'm not sure what functionality the fpu example is trying to demonstrate but I think it makes no sense. clock_gettime
is being used to get the timestamp used for time calculation, but this function itself takes ~1us, which means it should not be used to benchmark sub-us activities like simple floating point operations in this example. As shown in the following example:
#include <cmath>
#include <ctime>
#include "benchmark/cppbenchmark.h"
BENCHMARK("empty", CppBenchmark::Settings().Attempts(2).Duration(5)) {}
BENCHMARK("sin", CppBenchmark::Settings().Attempts(2).Duration(5)) {
[[maybe_unused]] static double sum = 0;
sum += sin(123.456);
}
BENCHMARK("timestamp", CppBenchmark::Settings().Attempts(2).Duration(5)) {
System::Timestamp();
}
BENCHMARK_MAIN()
Looks like cppbenchmark not working properly with gcc-13.
See my repo with some C++ benchmarks and issue: tilir/benchmarks#2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.