computation hoisting

Benchmark created on


Setup

const rowId = "prefix"
const entries = Array.from({length: 2000}, (_, idx) => {
	const rand = Math.random();
	return rand > 0.5 ?`${rowId}/${rand}` : `${rowId}`
})

Test runner

Ready to run.

Testing in
TestOps/sec
no hoisting
entries.filter(entry => entry === rowId || entry.startsWith(rowId + '/'))
ready
hoisting
const rowIdPrefix = rowId + '/'
entries.filter(entry => entry === rowId || entry.startsWith(rowIdPrefix))
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.