Literal construction vs memoised literal result

Benchmark created on


Setup

const firstName = 'John'
const lastName = 'Smith'
const extra = 'yada yada'
const extra2 = 'and yada'

const previousDependencies = [firstName, lastName, extra, extra2];

const memoisedValue = 'John Smith yada yada and yada'

Test runner

Ready to run.

Testing in
TestOps/sec
Template literal construction
const result = `${firstName} ${lastName} ${extra} ${extra2}`;
ready
Value comparison and return of memoised value
const dependencies = [firstName, lastName, extra, extra2]

if (dependencies.filter((value, i) => value !== previousDependencies[i]).length === 0) {
	return memoisedValue;
}
ready

Revisions

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