Created
June 14, 2019 15:12
-
-
Save xqms/d29764bcdeb0d0b49d5a4fd39497a4ec to your computer and use it in GitHub Desktop.
Corrade::Utility::Debug benchmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.0) | |
project(corrade_benchmark) | |
find_package(Corrade REQUIRED Utility) | |
set(CMAKE_CXX_STANDARD 17) | |
add_executable(corrade_benchmark main.cpp) | |
target_link_libraries(corrade_benchmark Corrade::Utility) | |
install(TARGETS corrade_benchmark RUNTIME DESTINATION bin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <sstream> | |
#include <Corrade/Utility/Debug.h> | |
#include <geiger/geiger.h> | |
int main(int argc, char** argv) | |
{ | |
// This is mandatory before running any benchmarks | |
geiger::init(); | |
// A benchmark suite that does only time measurement | |
{ | |
geiger::suite<> s; | |
s.add("Debug", []() | |
{ | |
Corrade::Utility::Debug{}; | |
}); | |
// Redirection of each test result to the "console" printer | |
s.set_printer<geiger::printer::console<>>(); | |
// Run each test during one second | |
s.run(); | |
} | |
std::cout << "\n\n"; | |
// A benchmark suite that does only time measurement | |
{ | |
geiger::suite<> s; | |
std::stringstream ss; | |
Corrade::Utility::Debug redirect{&ss}; | |
s.add("scoped debug", []() | |
{ | |
Corrade::Utility::Debug{} << "c"; | |
}); | |
// Redirection of each test result to the "console" printer | |
s.set_printer<geiger::printer::console<>>(); | |
// Run each test during one second | |
s.run(); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment