Skip to content

Commit 513bd8b

Browse files
committed
Add test to ensure plugin isn't adding overhead
1 parent 8c6ac14 commit 513bd8b

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

test/test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,34 @@ rollers.forEach(({rollup, version, opts, noTreeshake}) => {
199199
assert.is(count, 1)
200200
})
201201
}
202+
203+
if (version === 'latest') {
204+
test(`${version}: plugin shouldn't cause much overhead`, async (assert) => {
205+
let start
206+
let runs = 20
207+
let msDiffThreshold = 50
208+
209+
// bundle without plugin in use
210+
start = Date.now()
211+
for (let i = 0; i < runs; i++) {
212+
let bundle = await rollup(opts)
213+
await bundle.generate({format: 'cjs'})
214+
}
215+
let noPlugin = (Date.now() - start) / runs
216+
217+
// now with the plugin
218+
let count = 0
219+
let writeTo = (r) => ++count
220+
let rollOpts = Object.assign({plugins: [plugin({writeTo})]}, opts)
221+
start = Date.now()
222+
for (let i = 0; i < runs; i++) {
223+
let bundle = await rollup(rollOpts)
224+
await bundle.generate({format: 'cjs'})
225+
}
226+
let withPlugin = (Date.now() - start) / runs
227+
228+
assert.is(count, runs)
229+
assert.true((withPlugin - noPlugin) < msDiffThreshold)
230+
})
231+
}
202232
})

0 commit comments

Comments
 (0)