This repo contains a set of binaries in various languages that do something slightly more complicated than a typical "hello, world" program: it either records how long it takes to start up, or starts a subprocess and waits for it to complete.
In more detail, each program, if invoked directly (as determined by START not
being set in the program's environment):
- Records the current time as an integer number of nanoseconds from
the Unix epoch (1/1/1970 00:00:00 UTC) and sets the environment value
STARTto that value. - Takes the command line args passed to it and uses it to invoke a command in a subprocess (passing along the environment with the START value set).
- Prints how long it takes to start the subprocess (without waiting for it to complete), in the format "spawn %.6f secs". stdin, stdout, and stderr should be passed unmodified to the subprocess, so the subprocess can be interactive (if so desired) and any output should be passed through transparently back to the terminal.
- Waits for the subprocess to complete.
- Prints how long the subprocess took to execute, in the format "total %.6f secs".
- Exits.
If the program is invoked and has START set in the environment, then
START is assumed to be an integer number of nanoseconds since the start
of the Unix epoch, and the program:
- Records the current timestamp in nanoseconds as above
- Prints the delta between the current timestamp and the value of START as a floating point number of seconds to six decimal places (i.e., microseconds).
- Exits.