博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c++ code time代码时汇总
阅读量:3960 次
发布时间:2019-05-24

本文共 989 字,大约阅读时间需要 3 分钟。

.h 文件

/* * commonfunction.h * *  Created on: Sep 2, 2019 *      Author: huanglei */#ifndef COMMONFUNCTION_H#define COMMONFUNCTION_Husing namespace std;extern map
timerMap;void start(const string& name);double stop(const string& name);

.cpp 文件

common#include "commonFunction.h"map
timerMap;void start(const string& name) {
// timerMap.clear(); timespec ts1; clock_gettime(CLOCK_REALTIME, &ts1); timerMap[name] = ts1;}double stop(const string& name) {
int isDebugAnalogOn=0; timespec ts1 = timerMap[name]; timespec ts2; clock_gettime(CLOCK_REALTIME, &ts2); double interval = (ts2.tv_sec - ts1.tv_sec)*1e3 + (ts2.tv_nsec - ts1.tv_nsec)/1e6;// GET_TESTFLOW_FLAG("debug_analog",&isDebugAnalogOn); if (isDebugAnalogOn) {
cout << "DEBUG: timer " << name << " = " << interval << " ms " ; } return interval;}

用例:

#include "commonFunction.h"void codeTime(){
start("timer") double codeTime=stop("timer") cout<
<

转载地址:http://asmzi.baihongyu.com/

你可能感兴趣的文章
linux signal 处理
查看>>
linux的system () 函数详解
查看>>
在shell脚本的第一行中,必须写#!/bin/bash
查看>>
一句话##错误 'ASP 0116' 丢失脚本关闭分隔符
查看>>
文件上传漏洞之.htaccess
查看>>
常见网络安全设备默认口令
查看>>
第三周任务,利用文件上传漏洞
查看>>
ctfhub 投稿彩蛋
查看>>
【Shiro_exploit】PYTHON报错解决:ModuleNotFoundError: No module named 'requests'
查看>>
一次很折腾的扩容,记录一下之后再整理
查看>>
VirtualBox虚拟机网络配置
查看>>
oracle vm virtualbox虚拟机下,CentOS7系统网络配置
查看>>
Windows 10下Docker使用经验谈
查看>>
centos下nmap安装和基础命令
查看>>
ubuntu出现有线已连接却无法上网
查看>>
一句话命令
查看>>
解决Linux CentOS中cp -f 复制强制覆盖的命令无效的方法
查看>>
wdcpv3升级到v3.2后,多PHP版本共存的安装方法
查看>>
centos tar压缩与解压缩
查看>>
Centos 7防火墙firewalld/iptables开放80端口
查看>>