2016-06-15 03:32:35 +00:00
|
|
|
#pragma once
|
|
|
|
|
2016-12-15 16:14:56 +00:00
|
|
|
#ifndef DEBUG
|
|
|
|
#error "Not a debug build..."
|
|
|
|
#endif
|
|
|
|
|
2016-11-20 22:04:31 +00:00
|
|
|
#include <chrono>
|
2016-11-25 07:42:31 +00:00
|
|
|
#include <iostream>
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-12-15 16:14:56 +00:00
|
|
|
#include "common.hpp"
|
|
|
|
|
|
|
|
POLYBAR_NS
|
2016-06-15 03:32:35 +00:00
|
|
|
|
2016-12-15 16:14:56 +00:00
|
|
|
namespace debug_util {
|
|
|
|
template <class T>
|
|
|
|
void loop(const T& expr, size_t iterations) noexcept {
|
|
|
|
while (iterations--) {
|
|
|
|
expr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
void execution_speed(const T& expr) noexcept {
|
|
|
|
auto start = std::chrono::high_resolution_clock::now();
|
|
|
|
expr();
|
|
|
|
auto finish = std::chrono::high_resolution_clock::now();
|
|
|
|
std::cout << "execution speed: " << std::chrono::duration_cast<std::chrono::milliseconds>(finish - start).count()
|
|
|
|
<< "ms" << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
void execution_speed(const T& expr, size_t iterations) noexcept {
|
|
|
|
execution_speed([=] { loop(expr, iterations); });
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
void memory_usage(const T& object) noexcept {
|
|
|
|
std::cout << "memory usage: " << sizeof(object) << "b" << std::endl;
|
|
|
|
}
|
2016-06-15 03:32:35 +00:00
|
|
|
}
|
|
|
|
|
2016-12-15 16:14:56 +00:00
|
|
|
POLYBAR_NS_END
|