Activation improvement, more robust timer.

This commit is contained in:
AlexeyAB
2018-09-27 23:10:54 +03:00
parent e203ab9046
commit c0e2512af2
9 changed files with 166 additions and 21 deletions

View File

@ -329,3 +329,59 @@ image image_data_augmentation(IplImage* ipl, int w, int h,
#endif // OPENCV
#if __cplusplus >= 201103L || _MSC_VER >= 1900 // C++11
#include <chrono>
#include <iostream>
static std::chrono::steady_clock::time_point steady_start, steady_end;
static double total_time;
double get_time_point() {
std::chrono::steady_clock::time_point current_time = std::chrono::steady_clock::now();
//uint64_t now = std::chrono::duration_cast<std::chrono::milliseconds>(current_time.time_since_epoch()).count();
return std::chrono::duration_cast<std::chrono::microseconds>(current_time.time_since_epoch()).count();
}
void start_timer() {
steady_start = std::chrono::steady_clock::now();
}
void stop_timer() {
steady_end = std::chrono::steady_clock::now();
}
double get_time() {
double took_time = std::chrono::duration<double>(steady_end - steady_start).count();
total_time += took_time;
return took_time;
}
void stop_timer_and_show() {
stop_timer();
std::cout << " " << get_time()*1000 << " msec" << std::endl;
}
void stop_timer_and_show_name(char *name) {
std::cout << " " << name;
stop_timer_and_show();
}
void show_total_time() {
std::cout << " Total: " << total_time * 1000 << " msec" << std::endl;
}
#else // C++11
#include <iostream>
double get_time_point() { return 0; }
void start_timer() {}
void stop_timer() {}
double get_time() { return 0; }
void stop_timer_and_show() {
std::cout << " stop_timer_and_show() isn't implemented " << std::endl;
}
void stop_timer_and_show_name(char *name) { stop_timer_and_show(); }
void total_time() {}
#endif // C++11