String.charAt Test

Benchmark created by udeleng on


Description

Test access using String.chartAt vs index access

Setup

function testStringChartAt(str, count) {
      var c;
      for (var i = 0; i < count; i++) {
        c = str.charAt(0);
      }
    }
    
    function testStringCharIndex(str, count) {
      var c;
      for (var i = 0; i < count; i++) {
        c = str[0];
      }
    }

Test runner

Ready to run.

Testing in
TestOps/sec
String.charAt
testStringChartAt('test', 10000)
ready
String char index
testStringCharIndex('test', 10000)
ready

Revisions

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

  • Revision 1: published by udeleng on