substring vs lastindexof

Benchmark created on


Setup

let str = "azezrjzelxckqjksldjiazknqsklcjqsklqd"

let search = "lxc";
let end = 20;
let beg = 4

Test runner

Ready to run.

Testing in
TestOps/sec
lastIndexOf
let index = str.lastIndexOf(search, end)

if(index < beg )

   index = -1
ready
substr
str.substring(beg, end).lastIndexOf(search)
ready

Revisions

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