1、内核空间
#include<time.h>
struct timeval stime,etime;
do_gettimeofday(&stime);
... ... ... ... ...
lsmfts_set_targe_focal(priv->lsMfts,focalLength); //设置targe focla值 focalvalue[0,100]
do_gettimeofday(&etime);
printk("----do_gettimeofday----of setFoccalLength_od time %d us----\n",(etime.tv_sec - stime.tv_sec)*1000000 + (etime.tv_usec - stime.tv_usec)); //即为时间差
return 0;
2、用户空间
#include <time.h>
#include <sys/time.h>
typedef unsigned long long guint64;
guint64 system_current_time_millis()
{
struct timeval tve;
gettimeofday(&tve,NULL);
guint64 sec=tve.tv_sec;
guint64 microseconds=tve.tv_usec;
guint64 total=sec*G_GINT64_CONSTANT(1000)+microseconds/G_GINT64_CONSTANT(1000);
return total;
}
guint64 system_current_time_nano()
{
struct timeval tve;
gettimeofday(&tve,NULL);
guint64 sec=tve.tv_sec;
guint64 microseconds=tve.tv_usec;
guint64 total=sec*G_GINT64_CONSTANT(1000*1000*1000)+microseconds*G_GINT64_CONSTANT(1000);
return total;
}
guint64 system_current_time_micro()
{
struct timeval tve;
gettimeofday(&tve,NULL);
guint64 sec=tve.tv_sec;
guint64 microseconds=tve.tv_usec;
guint64 total=sec*G_GINT64_CONSTANT(1000*1000)+microseconds;
return total;
}
guint64 time1= system_current_time_millis();
... ... ... ... ...
guint64 time2= system_current_time_millis();
printf("----system_current_time_micro:%llums-%llums = %llu ms----\n", time2,time1,time2-time1);