Substring replacement vs normal replacement

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
With substr
const text = "Okay, let me generate an image of a goat for you: ![Image](http://localhost:8788/gen/kj7ha9a0) I have generated a photo of a realistic looking goat standing on grass, viewed from a side profile angle. The image is in high definition detail."

const before = text.substring(0, 59);
const after = text.substring(93);

return before + "http://www.testytesty.com" + after;

ready
With replacement
const text = "Okay, let me generate an image of a goat for you: ![Image](http://localhost:8788/gen/kj7ha9a0) I have generated a photo of a realistic looking goat standing on grass, viewed from a side profile angle. The image is in high definition detail."

return text.replace(text, "http://www.testytesty.com")
ready

Revisions

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