|
@@ -41,19 +41,6 @@ public:
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- void print_time(const std::string& m_name, int64_t microseconds, double milliseconds, double seconds) {
|
|
|
|
- int name_width = static_cast<int>(m_name.length() + 2);
|
|
|
|
- int us_width = std::max(6 - name_width, 1);
|
|
|
|
- int ms_width = std::max(8 - name_width, 1);
|
|
|
|
- int s_width = std::max(10 - name_width, 1);
|
|
|
|
-
|
|
|
|
- printf("[%s] Elapsed time: %*lld us | %*.3f ms | %*.6f s\n",
|
|
|
|
- m_name.c_str(),
|
|
|
|
- us_width, static_cast<long long>(microseconds),
|
|
|
|
- ms_width, milliseconds,
|
|
|
|
- s_width, seconds);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
void stop_print() {
|
|
void stop_print() {
|
|
if (m_stopped) { // 如果已经停止并打印过,则直接返回
|
|
if (m_stopped) { // 如果已经停止并打印过,则直接返回
|
|
return;
|
|
return;
|
|
@@ -69,7 +56,11 @@ public:
|
|
double milliseconds = microseconds / 1000.0;
|
|
double milliseconds = microseconds / 1000.0;
|
|
double seconds = milliseconds / 1000.0;
|
|
double seconds = milliseconds / 1000.0;
|
|
|
|
|
|
- print_time(m_name, microseconds, milliseconds, seconds);
|
|
|
|
|
|
+ printf("[%*s] Elapsed time: %*lld us | %*.3f ms | %*.6f s\n", 10,
|
|
|
|
+ m_name.c_str(),
|
|
|
|
+ 6, static_cast<long long>(microseconds),
|
|
|
|
+ 6, milliseconds,
|
|
|
|
+ 6, seconds);
|
|
|
|
|
|
m_stopped = true; // 标记为已停止并打印
|
|
m_stopped = true; // 标记为已停止并打印
|
|
}
|
|
}
|