| 39 | } |
| 40 | |
| 41 | static uint64_t current_time(char cur[], int length) |
| 42 | { |
| 43 | struct timeval t; |
| 44 | gettimeofday(&t, nullptr); |
| 45 | struct tm tim; |
| 46 | ::localtime_r(&t.tv_sec, &tim); |
| 47 | snprintf(cur, length, "%04d-%02d-%02d %02d:%02d:%02d", |
| 48 | ((unsigned int)tim.tm_year + 1900) % 10000, |
| 49 | ((unsigned int)tim.tm_mon + 1) % 100, |
| 50 | (unsigned int)tim.tm_mday % 100, |
| 51 | (unsigned int)tim.tm_hour % 100, |
| 52 | (unsigned int)tim.tm_min % 100, |
| 53 | (unsigned int)tim.tm_sec % 100); |
| 54 | return ((uint64_t)t.tv_sec*1000 + t.tv_usec/1000); |
| 55 | } |
| 56 | |
| 57 | static void log_perf_counters() |
| 58 | { |