Skip to content

Commit

Permalink
Add test to ensure plugin isn't adding overhead
Browse files Browse the repository at this point in the history
  • Loading branch information
doesdev committed Jul 11, 2018
1 parent 8c6ac14 commit 513bd8b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,34 @@ rollers.forEach(({rollup, version, opts, noTreeshake}) => {
assert.is(count, 1)
})
}

if (version === 'latest') {
test(`${version}: plugin shouldn't cause much overhead`, async (assert) => {
let start
let runs = 20
let msDiffThreshold = 50

// bundle without plugin in use
start = Date.now()
for (let i = 0; i < runs; i++) {
let bundle = await rollup(opts)
await bundle.generate({format: 'cjs'})
}
let noPlugin = (Date.now() - start) / runs

// now with the plugin
let count = 0
let writeTo = (r) => ++count
let rollOpts = Object.assign({plugins: [plugin({writeTo})]}, opts)
start = Date.now()
for (let i = 0; i < runs; i++) {
let bundle = await rollup(rollOpts)
await bundle.generate({format: 'cjs'})
}
let withPlugin = (Date.now() - start) / runs

assert.is(count, runs)
assert.true((withPlugin - noPlugin) < msDiffThreshold)
})
}
})

0 comments on commit 513bd8b

Please sign in to comment.