From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3534 invoked by alias); 29 Sep 2004 03:02:16 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 3519 invoked from network); 29 Sep 2004 03:02:15 -0000 Received: from unknown (HELO ict.ac.cn) (159.226.39.7) by sourceware.org with SMTP; 29 Sep 2004 03:02:15 -0000 Received: (qmail 14097 invoked by uid 507); 29 Sep 2004 02:43:03 -0000 Received: from localhost (HELO webmail.ict.ac.cn) (tangyan@127.0.0.1) by ict.ac.cn with SMTP; 29 Sep 2004 02:43:03 -0000 Received: from 159.226.40.187 (SquirrelMail authenticated user tangyan); by webmail.ict.ac.cn with HTTP; Wed, 29 Sep 2004 10:43:03 +0800 (CST) Message-ID: <32879.159.226.40.187.1096425783.squirrel@159.226.40.187> Date: Wed, 29 Sep 2004 03:02:00 -0000 Subject: a weird problem with clock() From: tangyan@ict.ac.cn To: gcc-help@gcc.gnu.org User-Agent: SquirrelMail/1.4.3-RC1 MIME-Version: 1.0 Content-Type: text/plain;charset=gb2312 Content-Transfer-Encoding: 8bit X-SW-Source: 2004-09/txt/msg00321.txt.bz2 Hello, everyone. I have a weird problem with clock() in glibc and I have tried my best to solve it myself but it still doesn't work. My little program is as following: -------------------------------- #include #include int main() { int i, sum; clock_t start, end; start = clock(); for (i = 0; i < 10000; i++) { sum += i; } end = clock(); printf("start: %ld, end: %ld\n", start, end); return 0; } -------------------------------- The problem is in my box the output is ALWAYS "start: 0, end: 0". Environment: $uname -a => --------------------------- Linux client135 2.4.20-8smp #1 SMP Thu Mar 13 17:45:54 EST 2003 i686 i686 i386 GNU/Linux --------------------------- OS: Redhat 9.0 --------------------------- $cat /proc/cpuinfo => --------------------------- processor : 1 vendor_id : GenuineIntel cpu family : 15 model : 2 model name : Intel(R) Pentium(R) 4 CPU 2.60GHz stepping : 9 cpu MHz : 2593.519 cache size : 512 KB physical id : 0 siblings : 2 fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 2 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm bogomips : 5177.34 -------------------------- $ gcc -v => ---------------------------- Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux Thread model: posix gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5) ---------------------------- The output of `ldd' on the `test' generated by "gcc test.c -o test" is, ------------------------------ libc.so.6 => /lib/tls/libc.so.6 (0x42000000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) ------------------------------ What's wrong with my little program? I just do all the things exactly followed the `time & data' chapter in glibc manual, but the output is always ZERO. The return value of clock() is 0, so it seems no error (-1) occurs. But why it always return 0? Thank you very much! BHW: I have not subscribe this mailing list, so anyone having some idea about this problem please replys directly to my mailbox, thanks.