mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
Activation improvement, more robust timer.
This commit is contained in:
@ -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
|
Reference in New Issue
Block a user