String to Array (16bit)

JavaScript performance comparison

Test case created by Cong Liu

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var input = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer lectus quam, adipiscing sit amet lobortis eu, lacinia ac lacus. Etiam luctus commodo enim, sit amet iaculis ante dictum in. Ut ut eros sed lacus eleifend pretium. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum vel elit neque. Etiam fringilla lobortis arcu et sollicitudin. Nulla convallis augue at sapien tempor scelerisque. Donec felis mi, tempor sit amet aliquet et, laoreet id elit. Nunc mollis, arcu sed laoreet fermentum, ligula urna fringilla enim, vel dictum massa massa vel nibh. Pellentesque vel mauris massa. Phasellus vulputate nisl sit amet velit bibendum ac commodo quam interdum. Quisque sed enim neque, vitae faucibus augue. Nulla iaculis arcu a ligula congue convallis. Suspendisse bibendum tincidunt elit quis luctus. Donec consequat viverra urna in lacinia. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nunc sit amet.";
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Array
var length = input.length;
var result = new Array(length);
for (var i = 0; i < length; i++) {
  result[i] = input.charCodeAt(i);
}
var u16 = new Uint16Array(result);
pending…
Uint16Array
var length = input.length;
var u16 = new Uint16Array(length);
for (var i = 0; i < length; i++) {
  u16[i] = input.charCodeAt(i);
}
pending…

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

Compare results of other browsers

0 comments

Add a comment