程序运行时间c++/matlab
前言
一般在调试程序的过程中,需要查看代码运行速度的快慢,此时则需要计算代码的运行时间。
实验过程:
c++:
#include<iostream>
#include<time.h> void do_something()
{
for(int i=;i<;i++)
for(int j=;j<;j++)
;
} int main(int arg,char ** argv)
{
clock_t start = clock();
do_something();
clock_t end = clock();
double time = static_cast<double>(end-start)/CLOCKS_PER_SEC;//单位是秒.
std::cout << "time = " << time << std::endl;
return ;
}
matlab:
tStart = tic;
do_something();
tElapsed = toc(tStart); %second
完
做自己该做的事情,做自己喜欢做的事情,安静做一枚有思想的技术媛。
程序运行时间c++/matlab的更多相关文章
- 检测Java程序运行时间的2种方法(高精度的时间[纳秒]与低精度的时间[毫秒])
第一种是以毫秒为单位计算的. 代码如下: long startTime=System.currentTimeMillis(); //获取开始时间 doSomeThing(); //测试的代码段 lon ...
- PAT乙级 1026. 程序运行时间(15)
1026. 程序运行时间(15) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 要获得一个C语言程序的运行时间, ...
- VC中监测程序运行时间(二)-毫秒级
/* * 微秒级计时器,用来统计程序运行时间 * http://blog.csdn.net/hoya5121/article/details/3778487#comments * //整理 [10/1 ...
- PAT-乙级-1026. 程序运行时间(15)
1026. 程序运行时间(15) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 要获得一个C语言程序的运行时间, ...
- C#测量程序运行时间及cpu使用时间
转载:http://www.cnblogs.com/yanpeng/archive/2008/10/15/1943369.html 对一个服务器程序想统计每秒可以处理多少数据包,要如何做?答案是用处理 ...
- java中读取程序运行时间
第一种是以毫秒为单位计算的. Java代码 //伪代码 long startTime=System.currentTimeMillis(); //获取开始时间 doSomeThing(); // ...
- Java计算两个程序运行时间
一.获取系统当前时间 long startTime = System.currentTimeMillis(); //获取开始时间 doSomething(); //测试的代码段 long endTim ...
- 三种计算c#程序运行时间的方法
三种计算c#程序运行时间的方法 第一种: 利用 System.DateTime.Now // example1: System.DateTime.Now method DateTime dt1 = S ...
- 【转】c++ 获取程序运行时间
转自:http://blog.csdn.net/ghevinn/article/details/22800059 DWORD start_time=GetTickCount(); {...} DWOR ...
随机推荐
- C++反汇编书
1. <C++反汇编与逆向分析技术揭秘> 2.
- Bate冲刺四——《WAP团队》
β冲刺第四天 1. 今日完成任务情况以及遇到的问题. ①马麒.杜有海:记录功能完善情况 ②郝明宇:记录验收情况 ③马宏伟.周欣:后台前端数据连接 ④乌勒扎:综合测试 2.成员时间贡献 成员 马宏 ...
- Chrome与之驱动对应的版本
看到网上基本没有最新的chromedriver与chrome的对应关系表,便兴起整理了一份如下,希望对大家有用: chromedriver版本 支持的Chrome版本 v2.46 v71-73 v2. ...
- 二分检索函数lower_bound()和upper_bound()
二分检索函数lower_bound()和upper_bound() 一.说明 头文件:<algorithm> 二分检索函数lower_bound()和upper_bound() lower ...
- root登录不进去 dropbear ssh
安装好了dropbear, root 怎么也登录不进去. 看 /var/log/messages , 发觉有很多下面的消息, 网上查了一下, 发觉建个 /etc/shells 文件,然后把 /bin/ ...
- Failed to execute operation: No such file or directory(systemctl enable iptables.service)
在保存Iptables配置时:systemctl enable iptables.service 出现错误: Failed to execute operation: No such file or ...
- AND Graph CodeForces - 987F (状压)
链接 大意:给定$m$个数, 若$x\&y=0$, 则在$x$与$y$之间连一条无向边. 求无向图的连通块个数 暴力连边显然超时的, 可以通过辅助结点优化连边, 复杂度$O(n2^n)$ #i ...
- Python多线程多进程
一.线程&进程 对于操作系统来说,一个任务就是一个进程(Process),比如打开一个浏览器就是启动一个浏览器进程,打开一个记事本就启动了一个记事本进程,打开两个记事本就启动了两个记事本进程, ...
- 用DFS 解决全排列问题的思想详解
首先考虑一道奥数题目: □□□ + □□□ = □□□,要将数字1~9分别填入9个□中,使得等式成立.例如173+286 = 459.请输出所有合理的组合的个数. 我们或许可以枚举每一位上所有的数,然 ...
- pycharm在创建py文件时,自动添加文件头注释
File -> settings -> Editor-> File and Code Templates -> Python Script 添加内容: #!/usr/bin/e ...