#pragma once #include #include struct timer{ using clock = std::chrono::high_resolution_clock; using time = std::chrono::time_point; using seconds = std::chrono::duration; std::string name; time begin; bool active = true; timer(std::string name) : name(name) , begin(clock::now()) { std::cerr << name << std::endl; } void stop(){ if(!active) return; time end = clock::now(); std::cerr << "* " << from_duration(end - begin) << '\t' << name << std::endl; active = false; } ~timer(){ stop(); } static double from_duration(seconds s){ return s.count(); } };