IsUpper Speed Comparison (v5)

Revision 5 of this benchmark created by Velmont on


Setup

Util = {
    /**
     * @return true if ch is a upper-case letter
     */
    isUpper : function (ch) {
      return ch >=65 && ch <= 90;
    },
  
    isUpper2: function (ch) {
      var ucLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
      return ucLetters.indexOf(ch) != -1;
    },
  
    isUpper3: function(ch) {
      return ch.toUpperCase() === ch;
    },
  
    isUpper4: function(ch) {
      var check = /[:lower:]/;
      return check.test(ch);
    },
  }
  
  var c = "hello".charAt(0)

Test runner

Ready to run.

Testing in
TestOps/sec
isUpper
Util.isUpper(c)
ready
isUpper2
Util.isUpper2(c)
ready
isUpper3
Util.isUpper3(c)
ready
isUpper4
Util.isUpper4(c)
ready

Revisions

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