Add a throughput option enabled with "-t"

Refactor the code so that it is not all in main().
Merge pull request #3 from rosslagerwall/add-throughput

Add a throughput option enabled with "-t"