String to Char Array (long text)

JavaScript performance comparison

Revision 2 of this test case created by Lux

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
for of loop + push
let output = []
for (let c of sentence) {
	output.push(c)  
}
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…
Split
let output = sentence.split("")
pending…
Object.Assign
let output = Object.assign([],sentence)
pending…
Array.map
let output = [].map.call(sentence, c => c)
pending…
Array.from
let output = Array.from(sentence)
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