help / color / Atom feed
* wrong unit for TIMEFMT=%M
@ 2020-02-24 19:40 Stephane Chazelas
  0 siblings, 0 replies; only message in thread
From: Stephane Chazelas @ 2020-02-24 19:40 UTC (permalink / raw)
  To: Zsh hackers list

TIMEFMT=%M is meant to report memory usage in KiB, but it's not the
case in Linux and FreeBSD at least.

It seems like zsh's TIMEFMT has had a tormented history.

For %M,

2.00.03 had

case 'M': fprintf(stderr,"%ld",ru->ru_maxrss); break

In 2.2, that changed to

#if sun
case 'M': fprintf(stderr,"%ld",ru->ru_maxrss*pk); break;
fprintf(stderr, "%ld", ru->ru_maxrss / 1024);

(pk being the number of KiB per page).

It seemed to disappear altogether in 2.6 and came back circa
4.0.4 as 

fprintf(stderr, "%ld", ru->ru_maxrss / 1024);

GNU time's configure.ac has:

# What memory units are reported by getrusage(2) ?
if test -z "$time_getrusage_mem_units" ; then
  # if envvar 'time_getrusage_mem_units' isn't set,
  # autodetect based on OS.
  case "$host_os" in
                     time_getrusage_mem_units=kb ;;

    macos*|darwin*)  time_getrusage_mem_units=bytes ;;

    solaris*)        time_getrusage_mem_units=pages ;;

    # As a fallback, assume KB (the most common value).
    # Set the 'warn' variable to warn the user at the end
    # of ./configure
    *) time_getrusage_mem_units=kb

Suggesting zsh is only correct on macos/darwin atm.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-24 19:40 wrong unit for TIMEFMT=%M Stephane Chazelas


Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-workers

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git