Skip to content

Instantly share code, notes, and snippets.

@xqms
Created June 14, 2019 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xqms/d29764bcdeb0d0b49d5a4fd39497a4ec to your computer and use it in GitHub Desktop.
Save xqms/d29764bcdeb0d0b49d5a4fd39497a4ec to your computer and use it in GitHub Desktop.
Corrade::Utility::Debug benchmark
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)
#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