delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/10/12/05:29:02

Date: Sat, 12 Oct 2002 11:23:22 +0300
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: "Leonid Pauzner" <uue AT pauzner DOT dnttm DOT ru>
Message-Id: <6480-Sat12Oct2002112321+0200-eliz@is.elta.co.il>
X-Mailer: emacs 21.3.50 (via feedmail 8 I) and Blat ver 1.8.9
CC: djgpp AT delorie DOT com
In-reply-to: <2.7.9.191MP.H3U9EW@pauzner.dnttm.ru> (uue@pauzner.dnttm.ru)
Subject: Re: profiling with DJGPP
References: <2 DOT 7 DOT 9 DOT 191MP DOT H3U9EW AT pauzner DOT dnttm DOT ru>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> From: "Leonid Pauzner" <uue AT pauzner DOT dnttm DOT ru>
> Date: Sat, 12 Oct 2002 02:35:20 +0400 (MSD)
> 
> I am curious about the profile (attached below) I get from my program:
> a lot of time spent in  getenv, days_to_years, timesub etc.

It's impossible to tell anything specific without seeing your
program, or at least having a vague idea about what it does.

In general, time functions _are_ heavy, since the computations are
non-trivial and require iterations in some cases.  You shoulod try to
avoid calling time functions in inner loops of your program.

> Looking the libc sources (djlsr203.zip) I got an impression that
> 1) getenv implemented ineffectively - no hashing

How many environment variables do you have on your system?  Unless you
have many thousands, I think hashing will not improve things in any
significant manner.

> 2) getenv heavily used by timer functions for timezone info
>     (TZ, TZDIR, etc. - seems things are stored in static
>      variables but probably not in all places?)

Only once: the time functions cache the values of environment
variables.  If your program changes the environment a lot (by calling
putenv or setenv, for example), then caching could be ineffective,
since each time the environment changes, time functions must see if
some of their variables changed as well, and take note.  This is so
that setting TZ to a different value is correctly handled.

> 4) I was unable to link my program with profiled libc version

You don't need to do that.  Just pull the sources of the functions you
want to profile from the library, put them into your program, and
rebuild with -pg.

- Raw text -


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