delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/12/29/03:41:39

Date: Tue, 29 Dec 1998 10:24:24 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Robert Hoehne <robert DOT hoehne AT gmx DOT net>
cc: Peter Palotas <blizzar AT hem1 DOT passagen DOT se>, djgpp-workers AT delorie DOT com
Subject: Re: Profiling Problems.
In-Reply-To: <368807D0.A8B5E4F2@gmx.net>
Message-ID: <Pine.SUN.3.91.981229102345.15836R-100000@is>
MIME-Version: 1.0
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 <sys/time.h>
  
  volatile int sigtimr = 0;
! volatile int sigprof = 0;
  
  void
  _my_handler(int sig)
--- 4,10 ----
  #include <sys/time.h>
  
  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;
      }
    }
  

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019