Utils/VrUtils/Inc/VrDebugTime.h
杰仔 9bcdc61c5a 初始提交:Utils 工具库模块
包含以下子模块:
- VrCommon: 核心接口和数据结构
- VrUtils: 工具类库(JSON、log4cpp、tinyxml2、INI、MD5、CRC)
- CloudUtils: 点云工具
- DataUtils: 数据处理工具(CloudMathClac、CoordinateTransform)
- CloudView: 点云查看工具

功能说明:
- 提供项目通用的基础工具类和实用功能
- 支持 Windows (MSVC/MinGW) 和 Linux (ARM/x86_64) 平台
- 使用 Qt qmake 构建系统
- 所有模块编译为静态库
2026-02-18 16:00:16 +08:00

51 lines
1.3 KiB
C++

#pragma once
#include <string>
#include <thread>
#include <assert.h>
#include <ratio>
#include <chrono>
#include <sstream>
/// \brief
/// 输出运行时间
class CVrDebugTimer
{
public:
CVrDebugTimer(const char* szDesc)
: m_strFunName(szDesc)
{
m_tBegin = std::chrono::high_resolution_clock::now();
m_tRecordTime = m_tBegin;
printf("===[%s Runtime]===\n", m_strFunName.c_str());
}
~CVrDebugTimer()
{
std::chrono::high_resolution_clock::time_point tCur = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::ratio<1, 1000>> duration_ms(tCur - m_tBegin);
printf("===[%s Runtime %f ms]===\n", m_strFunName.c_str(), duration_ms.count());
}
void RecordTime(const char* szDesc)
{
std::chrono::high_resolution_clock::time_point tCur = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::ratio<1, 1000>> duration_ms(tCur - m_tRecordTime);
m_tRecordTime = tCur;
printf("===[%s Runtime %f ms]===\n", szDesc, duration_ms.count());
}
private:
std::string m_strFunName;
std::chrono::high_resolution_clock::time_point m_tBegin;
std::chrono::high_resolution_clock::time_point m_tRecordTime;
};
/// \brief
/// 打印运行时间
#define VRDEBUG_PRINT_TIME(_desc) CVrDebugTimer oFuncDebugTime(_desc)