Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: wrong unit for TIMEFMT=%M
- X-seq: zsh-workers 49093
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: wrong unit for TIMEFMT=%M
- Date: Sat, 19 Jun 2021 14:20:48 +0100
- Archived-at: <https://zsh.org/workers/49093>
- In-reply-to: <20200224194021.kibawzliyystsu7o@chazelas.org>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxx>
- References: <20200224194021.kibawzliyystsu7o@chazelas.org>
D'oh, I had already reported that last year in workers/45489:
(Ultrix also seemed to have a maxrss expressed in bytes
http://www.polarhome.com/service/man/?qf=getrusage&af=0&sf=0&of=Ultrix&tf=2
not that it matters today).
2020-02-24 19:40:21 +0000, Stephane Chazelas:
> 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;
> #else
> fprintf(stderr, "%ld", ru->ru_maxrss / 1024);
> #endif
>
> (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) ?
> warn_getrusage_mem_units=
> 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
> minix*|aix*|*bsd*|linux*|gnu*)
> 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
> warn_getrusage_mem_units=yes
> ;;
> esac
> fi
>
> Suggesting zsh is only correct on macos/darwin atm.
>
> --
> Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author