Add a throughput option enabled with "-t"

Refactor the code so that it is not all in main().