JamieMason/karma-benchmark — pull request #3 by lazd (2014-02-19 06:02:52+00:00)
Title: Support multiple suites, refactor to use suite() and benchmark(), include 

### Preface

As promised https://github.com/JamieMason/karma-benchmark/issues/2#issuecomment-34218445, here's a pull request with what I've been working on to make karma-benchmark fit my needs.

The goal is to provide the ability to run benchmarks, jsPerf style, via Karma. That is, to pit two different methods of doing the same thing against one another to see which is faster.

This pull request accomplishes that goal while still maintaining support for the continuous integration-focused JUnit reports.

### Changes:

* In order to more closely match the Benchmark.js API, refactor to use suite() and benchmark() instead of benchmark() and when()
* In order to support comparison between methods ala jsPerf, support multiple suites
* Support for `var suite = new Benchmark.Suite()` is dropped to enable this
* In order to enable robust reporters, add additional benchmark data to Karma result
* Update README to reflect changes
* Revise README instructions for clarity and simplicity
* Add instructions to README for command line reporting with karma-benchmark-reporter

### Reporting

To take advantage of the additional benchmark data, I created a reporter, [karma-benchmark-reporter](karma-benchmark-example), that reports on which benchmark was the fastest in a given suite using the data provided by karma-benchmark. It's very simple right now, but I intend to update it to match the work I did on [grunt-benchmark](https://github.com/shama/grunt-benchmark). Currently, it looks like this:

```
Chrome 32.0.1700 (Mac OS X 10.9.1) Array iteration: util.each at 19356910 ops/sec
Chrome 32.0.1700 (Mac OS X 10.9.1) Array iteration: Array.forEach at 2567531 ops/sec
Chrome 32.0.1700 (Mac OS X 10.9.1) Array search: util.contains at 12635982 ops/sec
Chrome 32.0.1700 (Mac OS X 10.9.1) Array search: Array.indexOf at 5828437 ops/sec
Chrome 32.0.1700 (Mac OS X 10.9.1)
Array iteration: util.each at 19356910 ops/sec (7.54x faster than Array.forEach)
Array search: util.contains at 12635982 ops/sec (2.17x faster than Array.indexOf)
```

### Example

I've created a sample project, [karma-benchmark-example](https://github.com/lazd/karma-benchmark-example), that puts all of this together.