LinuxÏÂCÓïÑÔ±à³Ì ʱ¼ä¸ÅÄî
ÕâÒ»ÕÂÎÒÃÇѧϰLinuxµÄʱ¼ä±íʾºÍ¼ÆË㺯Êý
1.ʱ¼äµÄ±íʾ
2.ʱ¼äµÄ²âÁ¿
3.¼ÆʱÆ÷µÄʹÓÃ
--------------------------------------------------------------------------------
1¡£Ê±¼ä±íʾ ÔÚ³ÌÐòµ±ÖÐ,ÎÒÃǾ³£ÒªÊä³öϵͳµ±Ç°µÄʱ¼ä,±ÈÈçÎÒÃÇʹÓÃdateÃüÁîµÄÊä³ö½á¹û.Õâ¸öʱºòÎÒÃÇ¿ÉÒÔʹÓÃÏÂÃæÁ½¸öº¯Êý
#include
time_t time(time_t *tloc);
char *ctime(const time_t *clock);
timeº¯Êý·µ»Ø´Ó1970Äê1ÔÂ1ÈÕ0µãÒÔÀ´µÄÃëÊý.´æ´¢ÔÚtime_t½á¹¹Ö®ÖÐ.²»¹ýÕâ¸öº¯ÊýµÄ·µ»ØÖµ¶ÔÓÚÎÒÃÇÀ´ËµÃ»ÓÐʲôʵ¼ÊÒâÒå.Õâ¸öʱºòÎÒÃÇʹÓõڶþ¸öº¯Êý½«ÃëÊýת»¯Îª×Ö·û´®. Õâ¸öº¯ÊýµÄ·µ»ØÀàÐÍÊǹ̶¨µÄ:Ò»¸ö¿ÉÄÜֵΪ. Thu Dec 7 14:58:59 2000 Õâ¸ö×Ö·û´®µÄ³¤¶ÈÊǹ̶¨µÄΪ26
2¡£Ê±¼äµÄ²âÁ¿ ÓÐʱºòÎÒÃÇÒª¼ÆËã³ÌÐòÖ´ÐеÄʱ¼ä.±ÈÈçÎÒÃÇÒª¶ÔËã·¨½øÐÐʱ¼ä·ÖÎö.Õâ¸öʱºò¿ÉÒÔʹÓÃÏÂÃæÕâ¸öº¯Êý.
#include
int gettimeofday(struct timeval *tv,struct timezone *tz);
strut timeval {
long tv_sec; /* ÃëÊý */
long tv_usec; /* ΢ÃëÊý */
};
gettimeofday½«Ê±¼ä±£´æÔڽṹtvÖ®ÖÐ.tzÒ»°ãÎÒÃÇʹÓÃNULLÀ´´úÌæ.
#include #include #include
void function()
{
unsigned int i,j;
double y;
for(i=0;i<1000;i++)
for(j=0;j<1000;j++)
y=sin((double)i);
}
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);
}
Õâ¸ö³ÌÐòÊä³öº¯ÊýµÄÖ´ÐÐʱ¼ä,ÎÒÃÇ¿ÉÒÔʹÓÃÕâ¸öÀ´½øÐÐϵͳÐÔÄܵIJâÊÔ,»òÕßÊǺ¯ÊýËã·¨µÄЧÂÊ·ÖÎö.ÔÚÎÒ»úÆ÷ÉϵÄÒ»¸öÊä³ö½á¹ûÊÇ: Used Time:0.556070
3¡£¼ÆʱÆ÷µÄʹÓà Linux²Ù×÷ϵͳΪÿһ¸ö½ø³ÌÌṩÁË3¸öÄÚ²¿¼ä¸ô¼Æ
Ïà¹ØÎĵµ£º
ÓÉÓÚÎÒÃÇÊÇÔÚ¾ÖÇøÍøÄÚÓûúÆ÷×ö²âÊÔ·þÎñÆ÷£¬»úÆ÷±È½Ï½ôÕÅ£¬¶øIPµØÖ·µ¹ÊDZȽϸ»Ó࣬ËùÒÔʹÓÃͬһ»úÆ÷µÄ¶àIPÀ´ÅäÖÃÐéÄâÖ÷»ú¾ÍÊÇÒ»¸ö²»´íµÄÑ¡ÔñÁË¡£ÒòΪÎÒ ÏëÔÚͬһ»úÆ÷ÉϽøÐÐÁ½¸öϵͳµÄ²¿Êð£¬ËùÒÔ¾ÍʹÓÃapacheÀ´½øÐÐÐéÄâÖ÷»úµÄ¶àIPÅäÖÃÁË¡£ºÃÁË£¬¿ªÊ¼ÎÒÃǵÄÅäÖÃÖ®ÂðÉ~~~
Ê×ÏȾÍÊÇapac ......
Ê×ÏÈÀ´Á˽âÒ»ÏÂlinuxÖзÖÇøµÄ¸ÅÄî¡£
ÔÚLinuxÖУ¬·ÖÇøÊÇÕâÑù±íʾµÄ
¡¡¡¡¡¡¡¡/dev/hda
¡¡¡¡¡¡¡¡/dev/hda1
¡¡¡¡¡¡¡¡/dev/hda2
¡¡¡¡¡¡¡¡/dev/hda5
¡¡¡¡¡¡¡¡/dev/sdb1
ÒÔ /dev/hda5 ΪÀý:
ÒòΪÔÚLinuxÖУ¬Ã¿Ò»¸öÉ豸¶¼ÊÇÓà /dev/ Îļþ¼ÐϵÄÒ»¸ö ......
CRT È«³Æ£ºVisual C++ C RunTime Lib ¾ÍÊÇCÔËÐÐʱ¿â¡£
×¢£º ÒÔÏÂÄÚÈݲ¿·ÖÒý×ÔCSNDÖÐÏà¹ØÌÖÂÛµÄÌû×Ó£¬²¢½áºÏ×Ô¼ºµÄÀí½âÕûÀí¶ø³É¡£½ö¹©²Î¿¼¡£
1)ÔËÐÐʱ¿â¾ÍÊÇ C run-time library£¬ÊÇ C ¶ø·Ç C++ ÓïÑÔÊÀ½çµÄ¸ÅÄî:È¡Õâ¸öÃû×Ö¾ÍÊÇÒòΪÄãµÄ C ³ÌÐòÔËÐÐʱÐèÒªÕâЩ¿âÖеĺ¯Êý.
2)C ÓïÑÔÊÇËùνµÄ“СÄں˔ÓïÑÔ£¬¾ÍÆäÓ ......
ǶÈëʽLinuxÄÚºËÓÅ»¯²Ã¼ô
ÓÅ»¯1¡¢È¡ÏûÐéÄâÄÚ´æµÄÖ§³Ö
General setup ---& ......
1£¬LinuxµÄI2CÇý¶¯¼Ü¹¹¸ÅÀÀ
LinuxÖÐI2C×ÜÏßµÄÇý¶¯·ÖΪÁ½¸ö²¿·Ö£¬×ÜÏßÇý¶¯£¨BUS£©ºÍÉ豸Çý¶¯£¨DEVICE£©¡£ÆäÖÐ×ÜÏßÇý¶¯µÄÖ°Ôð£¬ÊÇΪϵͳÖÐÿ¸öI2C×ÜÏßÔö¼ÓÏàÓ¦µÄ¶Áд·½·¨£¨±ÈÈ粻ͬµÄÖ÷оƬ¼¯³ÉµÄI2C¿ØÖÆÆ÷£©¡£µ«ÊÇ×ÜÏßÇý¶¯±¾Éí²¢²»»á½øÐÐÈκεÄͨѶ£¬ËüÖ»ÊÇ´æÔÚÔÚÄÇÀµÈ´ýÉ豸Çý¶¯µ÷ÓÃÆäº ......