Date: Tue, 29 Dec 1998 10:24:24 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Robert Hoehne cc: Peter Palotas , djgpp-workers AT delorie DOT com Subject: Re: Profiling Problems. In-Reply-To: <368807D0.A8B5E4F2@gmx.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp-workers AT delorie DOT com These are the diffs for the itimer test program from djtst202. I found this modified version more useful than the original one, since the latter masked several problems in the itimer implementation (which probably explains why didn't Tom uncover them in the first place ;-). Watching the delta time between signal handler invocations was particularly educational... *** tests/libc/posix/signal/itimer.c~0 Thu Jan 1 22:59:54 1998 --- tests/libc/posix/signal/itimer.c Sun Dec 27 22:03:52 1998 *************** *** 4,10 **** #include volatile int sigtimr = 0; ! volatile int sigprof = 0; void _my_handler(int sig) --- 4,10 ---- #include volatile int sigtimr = 0; ! volatile int sigprof = -1; void _my_handler(int sig) *************** main(int argc, char **argv) *** 24,34 **** --- 24,41 ---- struct itimerval tv; struct itimerval prof; int oldval=-1; + uclock_t tprev = uclock(); tv.it_value.tv_sec = 5; tv.it_value.tv_usec = 0; tv.it_interval.tv_sec= 0; tv.it_interval.tv_usec = 0; /* Set profiler timer to 0.2 sec */ + /* If you want to test better, try these values in addition to + 200000: + 50000 56000 100000 110000 250000 800000 970999. + + To test the functions work, make sure the time difference printed + (as a floating-point value) is close enough to tv_usec you used. */ prof.it_value.tv_sec = prof.it_interval.tv_sec = 0; prof.it_value.tv_usec= prof.it_interval.tv_usec= 200000; signal(SIGALRM, _my_handler); *************** main(int argc, char **argv) *** 41,49 **** { if (sigprof != oldval) { ! printf(" %d\r",sigprof); fflush(stdout); oldval = sigprof; } } --- 48,60 ---- { if (sigprof != oldval) { ! uclock_t tnow = uclock(); ! ! printf(" %d: %f\n",sigprof, ! ((double)(tnow - tprev))/UCLOCKS_PER_SEC); fflush(stdout); oldval = sigprof; + tprev = tnow; } }