split+join vs replace+regexp

Benchmark created on


Setup

const data = `
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
select "some_field" from "some_table" where "another_field" = '123'
`;

Test runner

Ready to run.

Testing in
TestOps/sec
split / join
data.split('\"').join('')
ready
replace / regexp
data.replace(/"/g, '')
ready

Revisions

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