General Purpose library for Freestanding C++ and POSIX systems
Nie możesz wybrać więcej, niż 25 tematów
Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
|
#pragma once
|
|
|
|
#include <chrono>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#ifndef NO_BENCH
|
|
#define NO_BENCH 1
|
|
#endif
|
|
|
|
constexpr bool do_bench = 1 - NO_BENCH;
|
|
|
|
template<typename fn>
|
|
std::chrono::microseconds time_operation(fn op) {
|
|
auto start = std::chrono::high_resolution_clock::now();
|
|
op();
|
|
auto time = std::chrono::high_resolution_clock::now() - start;
|
|
return std::chrono::duration_cast<std::chrono::microseconds>(time);
|
|
}
|
|
|
|
struct test_scaffold{
|
|
std::string name;
|
|
virtual int run() = 0;
|
|
virtual ~test_scaffold() = default;
|
|
};
|
|
|
|
extern std::vector<std::unique_ptr<test_scaffold>> tests;
|
|
|
|
struct append_test {
|
|
append_test(test_scaffold* ptr) {
|
|
tests.emplace_back(ptr);
|
|
}
|
|
};
|