test(benchmark): add ability to run 25 iterations of test, sampling only the last 20

This commit also breaks the functionality into smaller, more testable functions,
and adds some basic tests for the benchmarking too.