substring vs replace vs slice

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
substring
str = "http://google.com/"
str.substring(0, str.length - 1);
ready
replace
str = "http://google.com/"
str.replace(/\/+$/, "");
ready
slice
str = "http://google.com/"
str = str.slice(0, -1); 
ready

Revisions

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