[Toybox] [PATCH] Add "time -v".

Rob Landley rob at landley.net
Fri Nov 24 06:40:54 PST 2017


On 11/17/2017 02:18 PM, enh wrote:
> i'm not super convinced by this myself, so more of an RFC...
> specifically this was wanted for the "max rss" line, but it's not
> obviously a good way to measure that for anything but simple
> single-threaded/no-forking code (because of children).

Hmmm... there's no -v in ubuntu 14.04? Ah, stupid shell builtins, of
_course_ the FSF implemented two incompatible versions.

$ /usr/bin/time true
0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata
1708maxresident)k
0inputs+0outputs (0major+81minor)pagefaults 0swaps

The whitespace is broken on that. Great.

$ /usr/bin/time -v true
	Command being timed: "true"
	User time (seconds): 0.00
	System time (seconds): 0.00
	Percent of CPU this job got: 0%
	Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.00
	Average shared text size (kbytes): 0
	Average unshared data size (kbytes): 0
	Average stack size (kbytes): 0
	Average total size (kbytes): 0
	Maximum resident set size (kbytes): 1608
	Average resident set size (kbytes): 0
	Major (requiring I/O) page faults: 0
	Minor (reclaiming a frame) page faults: 78
	Voluntary context switches: 1
	Involuntary context switches: 1
	Swaps: 0
	File system inputs: 0
	File system outputs: 0
	Socket messages sent: 0
	Socket messages received: 0
	Signals delivered: 0
	Page size (bytes): 4096
	Exit status: 0

Why is all that indented? Where do you get _averages_ from?

Hmmm... how is it harvesting half that data? Swaps? Socket messages
sent? You'd want to get notified that the process was exiting, but fetch
its /proc info while it was still a zombie (which sounds like a job for
the ps/top infrastructure), but receiving the signal allows it to exit
so the data goes away before you can read it. Are they doing something
with ptrace? No, strace says it's getting all that data from wait4() and
never opening /proc, and then of course it's doing 8 gazillion
single-byte write() calls to produce output, because FSF.

Sigh, this is the kind of thing I'd normally throw on the todo heap
along with a toybox version of screen and "kill -r" (recursive: children
and grandchildren and...), but as long as you're sending me a patch I'll
assume you've already identified the interesting subset?

Hmmm...

Rob



More information about the Toybox mailing list