testing

Benchmark created on


Setup

let str = "abcdeaabbwecweccewewcabcdeaabbwecweccewewcabcdeaabbwecweccewewcabcdeaabbwecweccewewcabcdeaabbwecweccewewcefjenfejkfejejfewjwejkfewjneknsdkskdmksnmksanskanskaksdnsanadalkslkfmkrgkrnjhebevtdyuyergithiotmyoj,p;;,dkmibwyvywvwyvyeuenrengmro,rp,rp[hrpe[,reh.r][r,gr[pgr[ep,[l[p,[p,p[,[p,kkmiininih]]]]]]]]]"

Test runner

Ready to run.

Testing in
TestOps/sec
1
let res = "";
for (let i = 0; i < str.length; i++) {
    if (str[i] == "a") continue;
    res += str[i];
}
return res.split();
ready
2
let res = [];
for (let i = 0; i < str.length; i++) {
    if (str[i] == "a") continue;
    res.push(str[i]);
}
return res;
ready
3
const out = new Array(str.length);
let k = 0;
for (let i = 0; i < str.length; i++) {
  const c = str[i];
  if (c !== "a") out[k++] = c;
}
out.length = k;
return out;
ready
4
let res = "";
for (let i = 0; i < str.length; i++) {
	if (str[i] == "a") continue;
    res = `${res}${str[i]}`;
}
return res.split();
ready
5
let count = 0;
for (let i = 0; i < str.length; i++) if (str[i] !== "a") count++;
const out = new Array(count);
let k = 0;
for (let i = 0; i < str.length; i++) {
  const c = str[i];
  if (c !== "a") out[k++] = c;
}
return out;
ready
6
const arr = new Array(str.length);

let k = 0;
for (let i = 0; i < str.length; i++) {
  if (str[i] == "a") continue;
  arr[k++] = str[i];
}
arr.length = k;
return arr;
ready

Revisions

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