IsUpper Speed Comparison (v6)

Revision 6 of this benchmark created 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);
    },
  
    isUpper5: function(ch) {
        return !/[^A-Z]/.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
isUpper5
Util.isUpper5(c)
ready

Revisions

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