Move the benchmark logic in a module

This allows to use the bench tool from other applications.

Hi I've moved everything from `bin/bench` to `lib/bench.js` except for argument parsing. I'd like to use your benchmark from another application. If you're interested I'd also like to extend the benchmark to be more modular. I'll do it in another pull request.

Would be nice to publish it on npm
This whole block should be indented with 2 spaces.