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 ));
随机推荐
- MVC中使用内建的HTML辅助方法产生表单元素提交表单与button按钮事件的陷阱
网站模板页有个登陆的退出按钮,当点击时跳转到登陆页面. <button onclick="logout()" >退出</button> $("#l ...
- 未能加载文件或程序集“Microsoft.SQLServer.DTSRuntimeWrap”或它的某一个依赖项。试图加载格式不正确的程序。
只要将应用程序池中的是否启用32位应用程序改为支持就可以了
- 自动化测试 using System.Windows.Automation;
frameworke3.0 及以上 using System.Windows.Automation; UIAutomationClient.dll UIAutomationClientsideProv ...
- Android-----test----monkeyrunner
1.下载 monkey_recorder.py和monkey_playback.py这两个文件: 2.存放到对应的虚拟机的tools文件夹下,如我的 D:\adt-bundle-windows-x8 ...
- MongoDB学习笔记(入门)
一.文档的注意事项:1. 键值对是有序的,如:{ "name" : "stephen", "genda" : "male&quo ...
- How to acquire an Android phone with locked bootloader?
As we know that some devices come with locked bootloaders like Sony, HUAWEI, hTC...If you try to unl ...
- UITableView的创建及其一些常用方法
UITableView,它的数据源继承于UITableViewDataSource,它的委托UITableViewDelegate. 一.UITableView的创建 1.代码方式: UITableV ...
- 在Ubuntu上安装Mysql For Python
安装: 首先安装pip,并且把pip更新到最小版本 apt-get install python-pip pip install -U pip 安装mysql开发包 apt-get install p ...
- Web前端入门必学知识
入门主要有三个部分 一.html+css部分: 1.前端的入门门槛极低,体现在HTML和CSS上运行环境就是浏览器,html+css这部分特别简单,网上搜资料,书籍视频非常多.css中盒 ...
- Foundation ----->NSDictionary
/*_______________不可变字(NSDictionary)____________*/ //1.字典的创建 //值(value) NSArray *arr ...