Skip to content

Instantly share code, notes, and snippets.

@Gvozd
Created February 26, 2017 15:39
Show Gist options
  • Save Gvozd/291e4f0adf247ff70ed72150059e4977 to your computer and use it in GitHub Desktop.
Save Gvozd/291e4f0adf247ff70ed72150059e4977 to your computer and use it in GitHub Desktop.
Timings of call sinon-stubs
let sinon = require('.');
class Foo {
bar() {
}
}
test('without stubing');
sinon.stub(Foo.prototype, 'bar').callsFake(function() {});
test('with stubing');
function test(name) {
console.time(name);
let foo = new Foo();
for(let i = 0; i < 10 * 1000; i++) {
foo.bar();
}
console.timeEnd(name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment