disemvowel

Benchmark created on


Description

factchecking some twitter shitposting

Setup

var line = [];
var ch;
for (var i = 0; i < 10000; i++){
for (ch = 'A'; ch <= 'Z'; ch = String.fromCodePoint(ch.charCodeAt(ch)+1)){
	line.push(ch);
}
for (ch = 'a'; ch <= 'z'; ch = String.fromCodePoint(ch.charCodeAt(ch)+1)){
	line.push(ch);
}	
}
var text = line.join('')

Test runner

Ready to run.

Testing in
TestOps/sec
based
const disemvowel = (str) => {
  const vowels = ['a', 'e', 'i', 'o', 'u'];
  let newStr = "";
  for (let i = 0; i < str.length; i++) {
  	let char = str.charAt(i);
    if (vowels.indexOf(char) == -1) {
      newStr += char;
    }
  }
  return newStr;
};
disemvowel(text);
ready
regex
const disemvowel = (str) => {
  return text.replace(/[aeiou]/ig, '');	
};
disemvowel(text);
ready

Revisions

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