C/C++ 记录时间
http://stackoverflow.com/questions/2808398/easily-measure-elapsed-time
https://github.com/picanumber/bureaucrat/blob/master/time_lapse.h
The |
if (globals::gAMInstance->enableTrans()) {
clock_t begin = clock();
std::string ostr;
raw_string_ostream ostrstream(ostr);
ostrstream << *module;
std::ofstream ofs(globals::getOutputDir(ASSEMBLY_BEFORE_TRANS_LL_FILE));
ofs << ostrstream.str();
ofs.close();
outs() << "transforming ......\n";
legacy::PassManager PM;
// PM.add(new ProgTrans());
PM.run(*module);
outs() << "program transforming finished\n";
outs().flush();
clock_t end = clock();
double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
std::cerr << "Program transformation spends " << std::fixed
<< std::setprecision(4) << elapsed_secs << "s.\n";
// RWset RW(*globals::gCMInstance->getKModule()->module,
// shape::RWType::TRANS);
// RW.dump();
// RWset rwset(*(this->module), shape::RWType::STATE_CACHE);
// const Instruction &ins = module->begin()->back().front();
// errs() << "the live variables of " << ins << " :\n";
// auto s = rwset.readset(ins);
// s.dump();
// rwset.dump();
// exit(0);
}
|
You can abstract the time measuring mechanism and have each callable's run time measured with minimal extra code, just by being called through a timer structure. Plus, at compile time you can parametrize the timing type (milliseconds, nanoseconds etc). Thanks to the review by Loki Astari and the suggestion to use variadic templates. This is why the forwarded function call.
According to the comment by Howard Hinnant it's best not to escape out of the chrono system until we have to. So the above class could give the user the choice to call
and be most useful for clients that
The complete code can be found here. My attempt to build a benchmarking tool based on chrono is recorded here. If C++17's
to provide for callables that are pointers to member functions. |
C/C++ 记录时间的更多相关文章
- [转]IIS 日志记录时间和实际时间 不一样
今天偶然发现 2003 系统IIS 日志记录时间和实际时间总是差了8个小时,也就是慢了8个小时.苦苦找了半天才发现如下办法能解决 ,特发来分享下 解决1:如果 IIS日志记录默认使用的是W3C扩展日志 ...
- Sql查询今天、本周和本月的记录(时间字段为时间戳)
工作中遇到的问题,小结一下 查询今日添加的记录: select * from [表名] where datediff(day,CONVERT(VARCHAR(20),DATEADD(SECOND,[时 ...
- window.setTimeout和window.setInterval的区别,及用其中一个方法记录时间。
window.setTimeout(语句,时间)是在多久之后执行语句,语句只执行一次. window.setInterval(语句,时间)是每隔多久执行一次语句,语句循环执行. <!DOCTYP ...
- Linux系统如何记录时间
1.内核在开机启动的时候会读取RTC硬件获取一个时间作为初始基准时间,这个基准时间对应一个jiiffies值(这个基准时间换算成jiffies值的方法是:用这个时间减去1970-01-01 00:0 ...
- 记录——时间轮定时器(lua 实现)
很长一段时间里,我错误的认识了定时器.无意中,我发现了“时间轮”这个名词,让我对定时器有了新的看法. 我错误的认为,定时器只需要一个 tick 队列,按指定的时间周期遍历队列,检查 tick 倒计时满 ...
- JavaScript创建日志文件并记录时间的做法
作者:朱金灿 来源:http://blog.csdn.net/clever101 try { var WSShell = WScript.CreateObject("WScript.Shel ...
- C# txt格式记录时间,时间对比,决定是否更新代码记录Demo
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...
- FindControl什么时候才会使用ObjectFromHWnd函数呢?——VCL很难调试,加一个日志函数,记录时间
IsDelphiHandleFindVCLWindowfunction IsVCLControl(Handle: HWND): Boolean;function FindControl(Handle: ...
- Oracle 查询当前系统时间十分钟之前的记录,时间比较SQL
select * from t_register r ));
随机推荐
- selenium2.0(WebDriver) API
1.1 下载selenium2.0的包 官方download包地址:http://code.google.com/p/selenium/downloads/list 官方User Guide: h ...
- 如何在winform或者wpf里面打开浏览器并设置宽高位置
需要SHDocVw.dll 文件或AxSHDocVw.dll 文件,.net默认是没有的,先生产这两个文件,请在Visual Studio 命令提示符下运行下面的命令: aximp %WINDIR%\ ...
- ABP的第一个程序和遇到的一些问题
ABP在这里就不多介绍了.在这篇文章中主要介绍使用模板生成的ABP项目使用遇到的一些问题. 1.首先在http://www.aspnetboilerplate.com/ 官方网站上创建一个模板项目, ...
- 转载:最近有两款路由器D-link , Tenda分别被爆出固件中存在后门
最近有两款路由器分别被爆出固件中存在后门. D-link D-link是台湾公司,成立于1986年,『公司致力于高级网络.宽带.数字.语音和数据通信解决方案的设计.制造和营销,是业界的全球领导者』(官 ...
- Geodatabase数据模型
1 Geodatabase概念 Geodatabase是ArcInfo8引入的一种全新的面向对象的空间数据模型,是建立在DBMS之上的统一的.智能的空间数据模型.“统一”是指,Geodatabase ...
- Extjs 百度地图扩展
var bmapps; Bsprint.EditMapInfoWindow = Ext.extend(Ext.Window, { form: null, constructor: function ( ...
- How browsers work
这几天翻译一篇旧文 How browsers work ( 以现代浏览器chrome.火狐.safari 为对象来分析),这篇文章网上有其他的翻译版本,自己再翻译一遍主要是练习阅读英文文章,而且自己翻 ...
- jmeter上传文件搞了一天,才搞定,没高人帮忙效率就是低,赶紧记下来,以备后用
先用谷歌浏览器抓包,抓到的包类似这样: 在jmeter里添加一个http请求,配置好参数,方法,端口,路径等, 勾选 在“同请求一起发送参数”里填写上面抓包的部分数据: 分别对应录入,勾选“编码” 我 ...
- Nginx配置location总结及rewrite规则写法
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 32.0px "Helvetica Neue"; color: #323333 } p. ...
- NPM 相关
1. 官方网站 https://docs.npmjs.com/ 2. 显示Global Module安装过什么 p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font ...