# timer **Repository Path**: liwei-nj/timer ## Basic Information - **Project Name**: timer - **Description**: 封装C++标准时钟库,实现简单易用的计时器功能,可以用来统计代码执行时间等。 - **Primary Language**: C++ - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2021-04-18 - **Last Updated**: 2022-04-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # timer #### 介绍 封装C++标准时钟库,实现简单易用的计时器功能,可以用来统计代码执行时间等。 #### 软件架构 软件架构说明 #### 安装教程 1. xxxx 2. xxxx 3. xxxx #### 使用说明 本计时器类和一些类型被封装在命名空间liwei中,因此需要using此命名空间。 1. 计算单个函数完整执行时间,单位为毫秒(s) ``` using namespace liwei; void fun(){ Timer timer("Titile time (s):"); //代码 } ``` 2. 计算某个代码段执行时间,单位秒(ms): ``` using namespace liwei; void fun(){ //代码 { Timer timer("Titile time (ms):"); //代码 } //代码 } ``` 3. 通过变量返回结果: ``` using namespace liwei; void fun(){ double time = 0; { Timer timer(time); //代码 } std::cout << "time (min):" << time << std::end; } ``` 4. 获取某个时间点距离对象定义点的时间差 ``` using namespace liwei; void fun(){ Timer timer(); //代码 std::cout << "elapsed time (ms):" << timer.GetElapsedTime() << std::endl; //打印距离起始点的时间差 //代码 std::cout << "elapsed time (min):" << timer.GetElapsedTime() << std::endl; //打印距离起始点的时间差 ....... } ``` 5. 获取相对于上一次获取点的时间差(相对时间) ``` void fun(){ Timer timer(); //代码 std::cout << "span time (s):" << timer.GetSpanTime() << std::endl; // //代码 std::cout << "span time (hour):" << timer.GetSpanTime() << std::endl; //打印距离上一个GetSpanTime()的时间差 ....... } ``` #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request #### 特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)