Have an RAII type that marks the code as time.
struct timed {
char const* name;
clock_t start;
timed( char const* name_to_record):
name(name_to_record),
start(clock())
{}
~timed(){
auto end=clock();
std::cout << name << " execution time: " << (end-start) / CLOCKS_PER_SEC << std::endl;
}
};
Use him:
void foo(){
timed timer(__func__);
}
Far less noise.
. , , . cout esoecially endl ; , , . , , .