Add a bunch of command-line arguments, clean up some stuff
There are some minor cleanups in here, like using built-in modules for sleep (rather than FFI calls to libc), logging (rather than our own which just printed unconditionally), and errno (rather than bare integers), and some typo fixes.
Most of the meat is in making it configurable, e.g. adding command-line flags for output files, number of iterations, sampling interval, etc.