gettimeofday的使用
前言
好像只能在linux平台使用,在windows平台不能使用。。。。
#include <sys/time.h>
long cur_tp, cost_tp, tmp_tp;
struct timeval timep;
gettimeofday(&timep, NULL); // Start Time
cur_tp = (timep.tv_sec * 1000000) + (timep.tv_usec);
dosomething();
gettimeofday(&timep, NULL);
cost_tp = (timep.tv_sec * 1000000) + (timep.tv_usec) - cur_tp;
std::cout << "dosomething(): " << cost_tp << " us..." << std::endl;
注意:
1.GPU时间和CPU时间可能函数不一样,计算的时间会有差异;
参考
1.https://blog.csdn.net/qiuchangyong/article/details/68945482;
2.https://blog.csdn.net/light_in_dark/article/details/70327403;
完
gettimeofday的使用的更多相关文章
- clock()、time()、clock_gettime()和gettimeofday()函数的用法和区别【转】
转自:http://www.cnblogs.com/krythur/archive/2013/02/25/2932647.html 转自http://blog.sina.com.cn/s/blog_7 ...
- Linux时间函数之gettimeofday()函数之使用方法
1.简介: 在C语言中可以使用函数gettimeofday()函数来得到时间.它的精度可以达到微妙 2.函数原型: #include<sys/time.h> int gettimeofda ...
- C --gettimeofday===获取某个程序经历的时间
#include <stdio.h> #include <sys/time.h> #include <time.h> int gettimeofday(struct ...
- linux中C语言获取高精度时钟gettimeofday函数
前言: 在开发中,很多时候需要知道各个函数或者是某些设备对命令的操作用时,因此需要用到 gettimeofday 来获取当前时钟. 一,函数说明 #include int gettimeofd ...
- gettimeofday() 获取系统时间,精确到微秒 这个似乎只能在linux 下用,不能在windows 下用
struct timeval{ long int tv_sec; // 秒数 同time(NULL) 的返回值 long int tv_usec; // 微秒数 10 的6次方 }; struct t ...
- 【转】Linux时间函数之gettimeofday()函数之使用方法
原文网址:http://blog.csdn.net/tigerjibo/article/details/7039434 一.gettimeofday()函数的使用方法: 1.简介: 在C语言中可以使用 ...
- 想精度高,可以考虑用c语言中的函数gettimeofday
大家好: 在 win32 + bcb 时, 有个 GetTickCount() 返回第统启动到现在的 tick, 单位 ms.请问在 Linux + qt5 怎样实现呢? 如果用 QDateTime ...
- 使用gettimeofday测试函数运行的时间
#include <time.h> #include <stdio.h> #include<sys/time.h> #define NEW_TIME_VALE st ...
- Linux-C语言中gettimeofday()函数的使用方法(转载)
1.简介: 在C语言中可以使用函数gettimeofday()函数来得到时间.它的精度可以达到微妙 2.函数原型: #include<sys/time.h> int gettimeofda ...
- gettimeofday(struct timeval *tv, struct timezone *tz)函数
gettimeofday(struct timeval *tv, struct timezone *tz)函数 功能:获取当前精确时间(Unix时间) 其中: timeval为时间 truct tim ...
随机推荐
- Windows10中注册 regsvr32 xxx.ocx报错but the call to DIIRegisterServer failed with error code 0x80040200
网站中有读取居民身份证的机器,需要安装一些注册activeX控件然后进入指定目录下执行以下命令regsvr32 xxx.ocx报了个错: but the call to DIIRegisterServ ...
- Python day7_set集合的常用方法以及常用格式化的总结
1.集合的定义:集合是无序的,没有重合元素的集合 集合外使用{}符号,各元素用,连接 2.集合的常用方法 1.add增加元素 2.clear清除元素 3.copy浅拷贝 4.difference差集( ...
- Struts2文件上传的大小限制问题
问题:上传大文件报错…… 解决:修改struts.xml文件中的参数如下 <constant name="struts.multipart.maxSize" value= ...
- AES SBox的构造(python)
几点需要注意的,求解逆元的时候使用的是拓展欧几里得,但是那些运算规则需要变一变,模2的加减乘除(或者可以理解为多项式的运算) 在进行字节的仿射变换不用进行矩阵的运算. 一个矩阵和一个列向量进行运算的时 ...
- 创意时钟 人形时钟 可惜不是 https
; (function () { $('#header').css({ 'position':'relative' }).prepend('<div id="clockWrap&quo ...
- Linux 之 ./configure --prefix 命令
参考 http://blog.sina.com.cn/s/blog_406127500101dsmy.html 源码的安装一般由3个步骤组成:配置(configure).编译(make).安装(mak ...
- robot切换窗口
在用robot做自动化测试的时候,经常遇到新开窗口,需要切换窗口的情况. 两种方式来解决: (1)用robot的关键字来解决 实现窗口切换的功能 @{handlelist} List Windows ...
- sublime插件安装及常用插件配置
1.下载 :百度云 工具中 2.注册 sgbteam Single User License EA7E-1153259 8891CBB9 F1513E4F 1A3405C1 A865D53F 115F ...
- Spring boot实现监听Redis key失效事件实现和其它方式
需求: 处理订单过期自动取消,比如下单30分钟未支付自动更改订单状态 用户绑定隐私号码当订单结束取消绑定等 解决方案1: 可以利用redis自带的key自动过期机制,下单时将订单id写入redis,过 ...
- CentOS7.6 Install TensorFlow
1. install pip 1). yum -y install epel-release 2). yum install python-pip 3). pip install --upgra ...