String matching

Benchmark created on


Description

Seeing whether string.includes is signficantly less performant than slicing a known approximate position of the string then searching.

Setup

const cruft = "abcedfghi"; 

const needle = "needle"; 

const haystack = cruft+needle + cruft.repeat(1000); 

Test runner

Ready to run.

Testing in
TestOps/sec
String.includes
haystack.includes("needle"); 
ready
string.slice.includes
haystack.slice(8, 16).includes("needle");
ready

Revisions

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