소스 검색

update time

leon 4 주 전
부모
커밋
07fee62f3b
1개의 변경된 파일5개의 추가작업 그리고 14개의 파일을 삭제
  1. 5 14
      src/common/utils.hpp

+ 5 - 14
src/common/utils.hpp

@@ -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() {
         if (m_stopped) { // 如果已经停止并打印过,则直接返回
             return;
@@ -69,7 +56,11 @@ public:
         double milliseconds = microseconds / 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; // 标记为已停止并打印
     }