String to Char Array (long text)

JavaScript performance comparison

Revision 3 of this test case created by Mikael Sand

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  let sentence = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Split
let output = sentence.split("")
pending…
Object.Assign
let output = Object.assign([],sentence)
pending…
for i loop + push
let output = []
for(i=0; i < sentence.length; i++) {
   output.push(sentence[i])
}
pending…
Spread Operator
let output = [...sentence]
pending…
Array.map
let output = [].map.call(sentence, c => c)
pending…
while loop + assign
let length = sentence.length;
let output = new Array(length);
while (length--) {
   output[length] = sentence[length];
}
pending…
Array.from
let output = Array.from(sentence)
pending…
for of loop + push
let output = []
for (let c of sentence) {
	output.push(c)  
}
pending…

Compare results of other browsers

Revisions

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

0 Comments