網站首頁 編程語言 正文
C++ 使用Poco庫實現代碼運行時間統計
flyfish
代碼解釋
start開始計時
elapsedSeconds 從start到此處統計運行時間,單位秒
elapsed 從start到此處統計運行時間,單位微妙
reset 重新設置即計時停止,未開始狀態
restart 重新開始計時 = reset + start
resolution 表示精確度
代碼實現
#include
#include
#include
#include
int main(int argc, char *argv[])
{
Poco::Stopwatch sw;
sw.start();
std::this_thread::sleep_for(std::chrono::seconds(2) );
std::cout <<sw.elapsedSeconds()<< std::endl;//second
std::cout <<sw.elapsed()<< std::endl;// microsecond
sw.reset();
std::this_thread::sleep_for(std::chrono::seconds(1) );
std::cout <<sw.elapsedSeconds()<< std::endl;
sw.start();
std::this_thread::sleep_for(std::chrono::seconds(1) );
std::cout <<sw.elapsedSeconds()<< std::endl;
std::cout <<"resolution:"<<sw.resolution()<<std::endl;
}
結果
2
2000824
0
1
resolution:1000000
原文鏈接:https://blog.csdn.net/flyfish1986/article/details/124696177
相關推薦
- 2022-01-28 Hyper集成laravel中使用的blade模板
- 2022-04-18 Python讀取配置文件-ConfigParser的二次封裝方法_python
- 2022-12-28 React?Server?Component混合式渲染問題詳解_React
- 2022-11-22 Python網絡請求模塊urllib與requests使用介紹_python
- 2023-02-07 Redis?中ZSET數據類型命令使用及對應場景總結(案例詳解)_Redis
- 2022-10-27 Python使用pandas將表格數據進行處理_python
- 2022-12-24 C語言中的逗號運算符詳解_C 語言
- 2022-05-14 一起來學習React元素的創建和渲染_React
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支