2.时间的测量
有时候我们要计算程序执行的时间.比如我们要对算法进行时间分析.这个时候可以使用下面这个函数. #include
int gettimeofday(struct timeval *tv,struct timezone *tz);
strut timeval {
long tv_sec; /* 秒数 */
long tv_usec; /* 微秒数 */
};
gettimeofday将时间保存在结构tv之中.tz一般我们使用NULL来代替.
#include <sys/time.h>
#include<stdio.h>
#include<unistd.h>
void function()
{
unsigned int i,j;
double y;
for(i=0;i<1000;i++)
for(j=0;j<1000;j++)
;
}
main()
{
struct timeval tpstart,tpend;
float timeuse;
gettimeofday(&tpstart,NULL);
function();
gettimeofday(&tpend,NULL);
timeuse=1000000*(tpend.tv_sec-tpstart.tv_sec)+
tpend.tv_usec-tpstart.tv_usec;
timeuse/=1000000;
printf("Used Time:%f/n",timeuse);
exit(0);
}
这个程序输出函数的执行时间,我们可以使用这个来进行系统性能的测试,或者是函数算法的效率分析.在我机器上的一个输出结果是: Used Time:0.004443
分享到:
相关推荐
Time of day 3.2.0.unitypackage Time of day 3.2.0.unitypackage
unity白天黑夜时间交替动态天空Time of Day - Dynamic Sky Dom
unity制作动态天气系统的插件,可以模拟四季及24小时的天气变化
本插件仅限用于学习,商用请移步官方商店。用这个插件可以很方便的模拟一天中的任意时刻、天空的云层变化,可以设置经纬度,使用方便,体积小巧,效果还不错。
Unity一天二十四小时变化插件,Time of Day最新版。unity白天黑夜时间交替动态天空Time of Day
Time of Day is a package to render realistic dynamic sky domes with day and night cycle, realistic celestials, dynamic clouds and physically based atmospheric scattering. ...
HDRP Time Of Day - Lighting Weather Clouds v1.2.0
DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); long lTime = long.Parse(d + "0000"); TimeSpan toNow = new TimeSpan(lTime); DateTime dtResult = dtStart.Add(toNow)...
可以轻松实现Unity中天气和时间的光影变化
The dataset is intended to be used for training and evaluating computer vision models that can recognize and classify images based on the time of day. With this dataset, you can build models that can ...
untiy 支持动态天空插件。实现一天24小时,从早到晚的动态天空效果。sky dome.Time of DAY- Dynamic Sky Dome
Time of Day v3.3.0.rar
unity动态天气系统插件,内容有日夜交替,全局大气散射效果,动态云效果
Time of Day - Dynamic Sky Dome unity 天气系统
工作于156m,计算当前时间,精度6ns
simens insight是APOGEE® 楼宇自动化控制系统.
TimeOfDay
The effect of time of day on problem solving and classroom behavior Psychology in ihe Schools Volume 20. July. I983 THE EFFECT OF TIME OF DAY ON PROBLEM SOLVING AND CLASSROOM BEHAVIOR ROBERT ...
语法:tod = timeOfDay(time, outUnit) 输入参数: - 时间:datenum 时间戳-outUnit:以下字符串之一:'nanoseconds','microseconds','milliseconds', “秒”(默认)、“分钟”或“天” 输出参数: - tod:单位...
学完C#后,自己课后做着玩的!提供了源代码,和成品