c Óë c£«£«ÖеÄtimeÏà¹Øº¯Êý
±¾ÎÄ´Ó½éÉÜ»ù´¡¸ÅÄîÈëÊÖ£¬Ì½ÌÖÁËÔÚC/C++ÖжÔÈÕÆÚºÍʱ¼ä²Ù×÷ËùÓõ½µÄÊý¾Ý½á¹¹ºÍº¯Êý£¬²¢¶Ô¼Æʱ¡¢Ê±¼äµÄ»ñÈ¡¡¢Ê±¼äµÄ¼ÆËãºÍÏÔʾ¸ñʽµÈ·½Ãæ½øÐÐÁ˲ûÊö¡£±¾ÎÄ»¹Í¨¹ý´óÁ¿µÄʵÀýÏòÄãչʾÁËtime.hÍ·ÎļþÖÐÉùÃ÷µÄ¸÷ÖÖº¯ÊýºÍÊý¾Ý½á¹¹µÄÏêϸʹÓ÷½·¨¡£
¹Ø¼ü×Ö£ºUTC£¨ÊÀ½ç±ê׼ʱ¼ä£©£¬Calendar Time£¨ÈÕÀúʱ¼ä£©£¬epoch£¨Ê±¼äµã£©£¬clock tick£¨Ê±ÖÓ¼Æʱµ¥Ôª£©
1.¸ÅÄî
ÔÚC/C++ÖУ¬¶Ô×Ö·û´®µÄ²Ù×÷ÓкܶàÖµµÃ×¢ÒâµÄÎÊÌ⣬ͬÑù£¬C/C++¶Ôʱ¼äµÄ²Ù×÷Ò²ÓÐÐí¶àÖµµÃ´ó¼Ò×¢ÒâµÄµØ·½¡£×î½ü£¬ÔÚ¼¼ÊõȺÖÐÓкܶàÍøÓÑÒ²¶à´ÎÎʵ½ ¹ýC++ÓïÑÔÖжÔʱ¼äµÄ²Ù×÷¡¢»ñÈ¡ºÍÏÔʾµÈµÈµÄÎÊÌâ¡£ÏÂÃ棬ÔÚÕâƪÎÄÕÂÖУ¬±ÊÕß½«Ö÷Òª½éÉÜÔÚC/C++ÖÐʱ¼äºÍÈÕÆÚµÄʹÓ÷½·¨¡£
ͨ¹ýѧϰÐí¶àC/C++¿â£¬Äã¿ÉÒÔÓкܶà²Ù×÷¡¢Ê¹ÓÃʱ¼äµÄ·½·¨¡£µ«ÔÚÕâ֮ǰÄãÐèÒªÁ˽âһЩ“ʱ¼ä”ºÍ“ÈÕÆÚ”µÄ¸ÅÄÖ÷ÒªÓÐÒÔϼ¸¸ö£º
Coordinated Universal Time£¨UTC£©£ºÐµ÷ÊÀ½çʱ£¬ÓÖ³ÆΪÊÀ½ç±ê׼ʱ¼ä£¬Ò²¾ÍÊÇ´ó¼ÒËùÊìÖªµÄ¸ñÁÖÍþÖαê׼ʱ¼ä£¨Greenwich Mean Time£¬GMT£©¡£±ÈÈ磬ÖйúÄڵصÄʱ¼äÓëUTCµÄʱ²îΪ+8£¬Ò²¾ÍÊÇUTC+8.ÃÀ¹úÊÇUTC-5.
Calendar Time£ºÈÕÀúʱ¼ä£¬ÊÇÓÓ´ÓÒ»¸ö±ê׼ʱ¼äµãµ½´ËʱµÄʱ¼ä¾¹ýµÄÃëÊý”À´±íʾµÄʱ¼ä¡£Õâ¸ö±ê׼ʱ¼äµã¶Ô²»Í¬µÄ±àÒëÆ÷À´Ëµ»áÓÐËù²»Í¬£¬µ«¶ÔÒ»¸ö±àÒëϵͳÀ´Ëµ£¬Õâ¸ö±ê׼ʱ¼äµãÊDz»±äµÄ£¬¸Ã±àÒëϵͳÖеÄʱ¼ä¶ÔÓ¦µÄÈÕÀúʱ¼ä¶¼Í¨¹ý¸Ã±ê׼ʱ¼äµãÀ´ºâÁ¿£¬ËùÒÔ¿ÉÒÔ˵ÈÕÀúʱ¼äÊÇ“Ïà¶Ôʱ¼ä”£¬µ«ÊÇÎÞÂÛÄãÔÚÄÄÒ»¸öʱÇø£¬ÔÚͬһʱ¿Ì¶Ôͬһ¸ö±ê׼ʱ¼äµãÀ´Ëµ£¬ÈÕÀúʱ¼ä¶¼ÊÇÒ»ÑùµÄ¡£
epoch£ºÊ±¼äµã¡£Ê±¼äµãÔÚ±ê×¼C/C++ÖÐÊÇÒ»¸öÕûÊý£¬ËüÓôËʱµÄʱ¼äºÍ±ê׼ʱ¼äµãÏà²îµÄÃëÊý£¨¼´ÈÕÀúʱ¼ä£©À´±íʾ¡£
clock tick£ºÊ±ÖÓ¼Æʱµ¥Ôª£¨¶ø²»°ÑËü½Ð×öʱÖӵδð´ÎÊý£©£¬Ò»¸öʱÖÓ¼Æʱµ¥ÔªµÄʱ¼ä³¤¶ÌÊÇÓÉCPU¿ØÖƵġ£Ò»¸öclock tick²»ÊÇCPUµÄÒ»¸öʱÖÓÖÜÆÚ£¬¶øÊÇC/C++µÄÒ»¸ö»ù±¾¼Æʱµ¥Î»¡£
ÎÒÃÇ¿ÉÒÔʹÓÃANSI±ê×¼¿âÖеÄtime.hÍ·Îļþ¡£Õâ¸öÍ·ÎļþÖж¨ÒåµÄʱ¼äºÍÈÕÆÚËùʹÓõķ½·¨£¬ÎÞÂÛÊÇÔڽṹ¶¨Ò壬»¹ÊÇÃüÃû£¬¶¼¾ßÓÐÃ÷ÏÔµÄCÓïÑÔ·ç¸ñ¡£ÏÂÃ棬ÎÒ½«ËµÃ÷ÔÚC/C++ÖÐÔõÑùʹÓÃÈÕÆÚµÄʱ¼ä¹¦ÄÜ¡£
2. ¼Æʱ
C/C++ÖеļÆʱº¯ÊýÊÇclock£¨£©£¬¶ø
Ïà¹ØÎĵµ£º
c:\progra~1 ÕâÖÖĿ¼ÊÇÔÚ´¿DOSÏ¿´µ½µÄ,´¿DOSʹÓÃ8+3Îļþ¸ñʽ,Ò²¾ÍÊÇ˵ÎļþÃû×î¶à²»³¬¹ý8¸ö×Ö·û,À©Õ¹Ãû×î¶à²»³¬¹ý3¸ö×Ö·û,³¤ÎļþÃû¾Í²ÉÓõÚ7¸ö×Ö·ûΪ~µÚ8¸ö×Ö·û°´ÓÐûÓÐÖظ´µÄÅÅÁË.ËùÒÔ´°¿ÚϵÄc:\program files Îļþ¼Ð½øÈë´¿DOS¿´µ½µÄÊÇc:\progra~1 ,
Õâ¸ö±»ÑÓÐøµ½WINDOWSÖÐ,Ò²ÊÇÒòΪµØÖ·Ì«³¤²Åд³ÉÕâÑùµÄ.ÒòΪֻÄÜÊäÈ ......
ÔÎÄ£ºhttp://hi.baidu.com/magicdemon/blog/item/821b2e22d7df494cad34debd.html
C++Ï»ù±¾ÀàÐÍËùռλÊýºÍÈ¡Öµ·¶Î§£º
·ûºÅÊôÐÔ ³¤¶ÈÊôÐÔ »ù±¾ÐÍ ËùռλÊý È¡Öµ·¶Î§ ÊäÈë·û¾ÙÀý&n ......
C/C++³ÌÐòԱӦƸ³£¼ûÃæÊÔÌâÉîÈëÆÊÎö(2)
×÷ÕߣºËᦻª e-mail:21cnbao@21cn.com ³ö´¦£ºÈí¼þ±¨
3.ÄÚ¹¦Ìâ
ÊÔÌâ1£º·Ö±ð¸ø³öBOOL£¬int£¬float£¬Ö¸Õë±äÁ¿ Óë“ÁãÖµ”±È½ÏµÄ if Óï¾ä£¨¼ÙÉè±äÁ¿ÃûΪvar£©
½â´ð£º
BOOL ÐͱäÁ¿£ºif(!var)
int ÐͱäÁ¿£º if(var==0)
float ÐͱäÁ¿£º
const float EPSINON = 0.00 ......
ÔÚÇ°ÃæµÄ»ù´¡ÉÏ£¬ÏÂÃ濪ʼÀûÓÃskyeye×Ô´øµÄtestsuitesÖеÄ×ÊÔ´À´ÔËÐÐ×Ô¼ºµÄ³ÌÐòµÄ·½·¨
1.Ê×ÏÈÊÇÏÂÔØÏÂÔØskyeye-1.2.5_REL.tar.gz£¬È»ºó½âѹ¸ÃÎļþ
2.ʹÓÃskyeyeÄ£Äâ°å×Ós3c2410ÔËÐÐij¸ölinux
Ê×ÏȽøÈë½âѹÍêµÄĿ¼£¬È»ºó
cd ./linux/s3c2410/s3c2410x-2.6.14
skyeye –c skyeye.conf –e vmlinux
×¢ÒâµÄÊÇs ......