LinuxÏÂʱ¼ä¶ÈÁ¿µÄÉîÈë·ÖÎö
Ò»)ANSI clockº¯Êý
1)¸ÅÊö:
clock º¯ÊýµÄ·µ»ØÖµÀàÐÍÊÇclock_t,Ëü³ýÒÔCLOCKS_PER_SECÀ´µÃ³öʱ¼ä,Ò»°ãÓÃÁ½´Îclockº¯ÊýÀ´¼ÆËã½ø³Ì×ÔÉíÔËÐеÄʱ¼ä.
ANSI clockÓÐÈý¸öÎÊÌâ:
1)Èç¹û³¬¹ýÒ»¸öСʱ,½«Òªµ¼ÖÂÒç³ö.
2)º¯ÊýclockûÓп¼ÂÇCPU±»×Ó½ø³ÌʹÓõÄÇé¿ö.
3)Ò²²»ÄÜÇø·ÖÓû§¿Õ¼äºÍÄں˿ռä.
ËùÒÔclockº¯ÊýÔÚlinuxϵͳÉϱäµÃûÓÐÒâÒå.
2)²âÊÔ
±àдtest1.c³ÌÐò,²âÊÔ²ÉÓÃclockº¯ÊýµÄÊä³öÓëtime³ÌÐòµÄÇø±ð.
vi test1.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main( void )
{
long i=1000L;
clock_t start, finish;
double duration;
printf( "Time to do %ld empty loops is ", i );
start = clock();
while (--i){
system("cd");
}
finish = clock();
duration = (double)(finish - start) / CLOCKS_PER_SEC;
printf( "%f seconds\n", duration );
return 0;
}
gcc test1.c -o test1
time ./test1
Time to do 1000 empty loops is 0.180000 seconds
real 0m3.492s
user 0m0.512s
sys 0m2.972s
3)×ܽá:
(1)³ÌÐòµ÷Óà system("cd");£¬ÕâÀïÖ÷ÒªÊÇϵͳģʽ×Ó½ø³ÌµÄÏûºÄ,test1³ÌÐò²»ÄÜÌåÏÖÕâÒ»µã.
(2)0.180000 secondsÃëµÄÏûºÄÊÇÁ½´Îclock()º¯Êýµ÷ÓóýÒÔCLOCKS_PER_SEC.
(3)clock()º¯Êý·µ»ØÖµÊÇÒ»¸öÏà¶Ôʱ¼ä£¬¶ø²»ÊǾø¶Ôʱ¼ä.
(4)CLOCKS_PER_SECÊÇϵͳ¶¨ÒåµÄºê£¬ÓÉGNU±ê×¼¿â¶¨ÒåΪ1000000.
¶þ)times()ʱ¼äº¯Êý
1)¸ÅÊö:
ÔÐÍÈçÏ£º
clock_t times(struct tms *buf);
tms½á¹¹ÌåÈçÏÂ:
strace tms{
clock_t tms_utime;
clock_t tms_stime;
clock_t tms_cutime;
clock_t tms_cstime;
}
×¢ÊÍ:
tms_utime¼Ç¼µÄÊǽø³ÌÖ´ÐÐÓû§´úÂëµÄʱ¼ä.
tms_stime¼Ç¼µÄÊǽø³ÌÖ´ÐÐÄں˴úÂëµÄʱ¼ä.
tms_cutime¼Ç¼µÄÊÇ×Ó½ø³ÌÖ´ÐÐÓû§´úÂëµÄʱ¼ä.
tms_cstime¼Ç¼µÄÊÇ×Ó½ø³ÌÖ´ÐÐÄں˴úÂëµÄʱ¼ä.
2)²âÊÔ:
vi test2.c
#include <sys/times.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
static void do_cmd(char *);
st
Ïà¹ØÎĵµ£º
GNU glibcÌṩһ¸ö¶ÔprintfµÄÀ©Õ¹£¬Ö±½Óprintf("%m"),¿ÉÒÔÊä³ö±ê×¼µÄ´íÎóÐÅÏ¢£¬ÀýÈçÏÂÃ棺
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
int main()
{
......
תÔØ×Ô£ºhttp://fanqiang.chinaunix.net/a4/b8/20010811/0905001105.html
LinuxϵĶàÏ̱߳à³Ì
±¾Îijö×Ô:http://www.china-pub.com ×÷Õß: Ò¦¼Ì·æ (2001-08-11 09:05:00)
1
ÒýÑÔ
¡¡¡¡Ị̈߳¨thread£©¼¼ÊõÔçÔÚ60Äê´ú¾Í±»Ìá³ö£¬µ«ÕæÕýÓ¦ÓöàÏ̵߳½²Ù×÷ϵͳÖÐÈ¥£¬ÊÇÔÚ80Äê´úÖÐÆÚ£¬solarisÊÇÕâ·½ÃæµÄٮٮ ......
CPU²é¿´£º
1¡¢¡¡¡¡# dmesg | grep CPU
¡¡¡¡Initializing CPU#0
¡¡¡¡CPU: Trace
cache: 12K uops
¡¡¡¡CPU: L1 I-cache: 0K, L1 D-cache: 16K
¡¡¡¡CPU: L2
cache: 256K
¡¡¡¡Intel machine check reporting enabled on CPU#0.
¡¡¡¡
CPU: After generic, caps: bfebfbff 00000000 00000000 00000000
¡¡¡¡
CPU ......
1) È·±£¼ÆËã»úµÄ123¶Ë¿ÚûÓб»·À»ðǽ×èµ²£»
2) ÓÃrootµÇ¼£»
3) ÐÞ¸Ä/etc/crontabÎļþ£¬¼ÓÈëÒÔÏÂÒ»ÐÐÃüÁ
0 23 * * * root /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1
ÒÔÉÏÃüÁîÉèÖúúó´æÅÌ¡£ÄúµÄ»úÆ÷½«ÔÚÿÌìµÄ23:00¸ù¾Ý¹ú¼ÒÊÚʱÖÐÐĵÄNTP·þÎñÆ÷ʱ¼ä×Ô¶¯Ð£×¼Ê±¼ä¡£Èç¹ûÄúµÄ»úÆ÷²»ÄÜÁª½á»¥ÁªÍø£¬Ç ......
ÒÔÏÂת×Ô£ºhttp://www.lerich.com/viewthread.php?tid=640
Ö÷»úΪWindowsXPϵͳ£¬VMwareÐéÄâ»úÀï°²×°Linux²Ù×÷ϵͳ¡£°²×°ÍêVMwareºó£¬Ö÷»úµÄÍøÂçÁ¬½ÓÀïÃæ³öÏÖÁËÁ½¸öеÄÁ¬½Ó£¬¼´VMware Network Adapter VMnet1ºÍVMware Network Adapter VMnet8Èçͼ¡£ÐéÄâ»úÀï°²×°µÄϵͳ¾ÍÊÇ¿¿ÕâÁ½¸öÐéÄâÍø¿¨À´ÁªÍøµÄ¡££¨ÈçÏÂͼ£©
Ö÷»úÉÏÀ ......