JamieMason / JamieMason/karma-benchmark
Broken suite parameters assignement
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 90
- Forks
- 16
- PR merge metrics
- No merged PRs in 30d
Description
The suite wrapper function is unable to setup benchmarks with his onStart stuff.
```javascript
suite(
'Suite options',
function () {
benchmark('_.each', function () {
_.each(this.list, function (number) {
return number;
});
});
benchmark('native forEach', function () {
this.list.forEach(function (number) {
return number;
});
});
},
{
onCycle: function (event) {
var suite = this;
var benchmark = event.target;
console.log('Cycle completed for ' + suite.name + ': ' + benchmark.name);
},
onStart: function () {
this.list = [5, 4, 3];
},
onComplete: function () {
this.list = null;
}
}
);
```
This code come from the Readme and just crash because this.list does not exist in benchmark.
It throw:
```javascript
PhantomJS 2.1.1 (Windows 8 0.0.0) Suite options: native forEach FAILED
TypeError: undefined is not an object (evaluating 'this.list.forEach')
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! karma-benchmark-examples@1.0.0 test: `karma start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the karma-benchmark-examples@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
```
This is the same with karma v3.0.0. You can find a working example [here](https://github.com/Itee/karma-benchmark/tree/fix_suite_setup)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the suite wrapper and the README example shown in the issue, then compare the behavior with the linked fix_suite_setup branch. Run npm test, which invokes karma start, and confirm that the onStart list is available to benchmark callbacks and the example no longer throws the reported TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- performance, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100