add timed_scope
This commit is contained in:
parent
ef2fa96a83
commit
29acbb6374
2 changed files with 16 additions and 0 deletions
15
src/prof.hpp
Normal file
15
src/prof.hpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
struct Prof_Scope_Print {
|
||||
Prof_Scope_Print(const char *name) : scope_name { name }, scope_start_t { std::chrono::high_resolution_clock::now() } {}
|
||||
~Prof_Scope_Print() {
|
||||
using namespace std::chrono;
|
||||
time_point scope_end_t = high_resolution_clock::now();
|
||||
duration scope_duration = duration_cast<microseconds>(scope_end_t - scope_start_t);
|
||||
fprintf(stderr, "[profile] %s took %.4f ms\n", scope_name, scope_duration.count() * 0.001f);
|
||||
}
|
||||
|
||||
const char *scope_name;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> scope_start_t;
|
||||
};
|
||||
|
||||
#define TIMED_SCOPE() const Prof_Scope_Print CONCAT_STR(_prof, __LINE__) { __func__ }
|
||||
#define TIMED_SCOPE_NAME(name) const Prof_Scope_Print CONCAT_STR(_prof, __LINE__) { name }
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include "types.h"
|
||||
#include "defer.hpp"
|
||||
#include "prof.hpp"
|
||||
#include "mem.h"
|
||||
#include "str.h"
|
||||
#include "rntuple.h"
|
||||
|
|
Loading…
Reference in a new issue