Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!tut!funic!csc.fi!sbs From: sbs@csc.fi Newsgroups: comp.lang.c Subject: Does times() work on SUN's properly ? Message-ID: <1990Aug16.190428.1@csc.fi> Date: 16 Aug 90 19:04:28 GMT Sender: usenet@nic.funet.fi Organization: Finnish Academic and Research Network Project - FUNET Lines: 54 I have problem on our SUN/3 or SUN/4 that I cannot get correct elapsed time (real time, wall clock time) from function times(). Following code works on Cray/UNICOS and Iris-4D (under SYSTEM V): #include #include #include #include time_t init_elapsed_time; /* usually time_t is typedefed to long */ struct tms timebuffer; /* extern time_t times(); */ void starttime() /* retrieve (elapsed) time since boot etc. */ { init_elapsed_time = times(&timebuffer); } void cputime(elapsed,usercpu,systemcpu) /* retrieve CPU etc times spent after doing something */ float *elapsed,*usercpu,*systemcpu; { *elapsed = (float) (times(&timebuffer)-init_elapsed_time) / HZ; *usercpu = (float) timebuffer.tms_utime/HZ; *systemcpu = (float) timebuffer.tms_stime/HZ; return; } main() { float e,u,s; starttime(); /* initialize init_elapsed_time (may not be zero!) */ /* do something */ cputime(&e,&u,&s); /* print times */ } And I will get that elapsed time (variable e) is equal to zero on our SUNs. What is going wrong here (on SUN)? Please answer me directly (to sbs@csc.fi) or via NEWS . --------- Sami Saarinen Centre for Scientific Computing