chai-performance

0.1.4 • Public • Published

chai-performance

js-standard-style npm version

Performance test plugin for the chai assertion libary, for the browser and node

var chai = require('chai')
var perf = require('chai-performance')
chai.use(perf)
 
// use this to enable or disable logs on success (enabled by default in node)
perf.log = true
 
describe('chai-performance', function () {
  it('division should be as fast as multiplication', function (done) {
    this.timeout(50e3)
    var amount = 1e6
    expect(function () {
      for (var i = 0, j; i < amount; i++) {
        j = i * 10
      }
    }).performance({
      margin: 1,
      loop:10,
      method: function () {
        for (var i = 0, j; i < amount; i++) {
          j = i / 10
        }
      }
    }, done)
  })
})

Package Sidebar

Install

npm i chai-performance

Weekly Downloads

1

Version

0.1.4

License

MIT

Last publish

Collaborators

  • vigour-io