The code, as the author makes clear, is an MWE. It provides a brief framework for benchmarking the behavior of the clocks. It's not intended to illustrate how to efficiently perform the task it's meant to resemble.
But it seems consequential. If the time were sampled every kilobyte, the code would be 1,000 times faster - which is better than the proposed use of other time functions.
At that point, even these slow methods are using about 0.5ms per million bytes, so it should be good up to gigabit speeds.
If that’s not fast enough, then sample every million bytes. Or, if the complexity is worth it, sample in an adaptive fashion.
At that point, even these slow methods are using about 0.5ms per million bytes, so it should be good up to gigabit speeds.
If that’s not fast enough, then sample every million bytes. Or, if the complexity is worth it, sample in an adaptive fashion.