clock函数

简介: clock函数

大家测试经常会出现超时问题,下面说一下怎么检测时间

先写头文件


#include<time.h>
int a,b,c;
 a=clock();


要测验的代码


b=clock();
c=b–a;
printf("%d",c);


时间超时就考虑怎么优化,c是毫秒

目录
相关文章
|
7月前
|
C++
c和c++中time , srand, rand 函数的使用
c和c++中time , srand, rand 函数的使用
|
9月前
|
Java
time类获取时间
time类获取时间
71 0
|
10月前
|
Linux
settime计时器和POSIX timer函数
settime计时器和POSIX timer函数
128 0
获取当前时间的函数 CURRENT_TIME 和 LOCALTIME
获取当前时间的函数 CURRENT_TIME 和 LOCALTIME
141 0
|
关系型数据库
Psqlgresql Time function时间函数
Psqlgresql Time function时间函数 select now() 获取的时间为什么一直不变 pg中获取时间的方式有多种 如果放在事务中,now()获取的就是事务开始的时间,事务不结束,时间不变;而clock_timestamp()显示的时间会实时变化。
1283 0
[LeetCode] Exclusive Time of Functions 函数的独家时间
Given the running logs of n functions that are executed in a nonpreemptive single threaded CPU, find the exclusive time of these functions.
951 0