for cache

JavaScript performance comparison

Test case created by juan

Preparation code

<FORM method=POST name="form">
<TABLE bgcolor="#e0c0c0" border=0 cellpading=5 cellspacing=5 style="-moz-border-radius:10">
 <TR>
  <TD>Username</TD>
  <TD><INPUT type="text" name="username" style="border:1px solid black"
        onfocus="window.status='Please enter your desired username';"
        onblur="window.status=window.defaultStatus; validateMandatory(this);">&nbsp;<FONT color="red">*</FONT></TD>
 </TR>
 <TR>
  <TD>Real name</TD>
  <TD><INPUT type="text" name="realname" onblur="validateMandatory(this);" style="border:1px solid black">&nbsp;<FONT color="red">*</FONT></TD>
 </TR>
 <TR>
  <!-- END Calendar control -->
  <TD>Birth date</TD>
  <TD><INPUT type="text" name="birthdate" style="border:1px solid black"> &nbsp; <input type="button" onclick="cal.popup('birthdate');" value="..." style="border:1px solid black"></TD>
 <TR>
  <TD>Email address</TD>
  <TD><INPUT type="text" name="email"  onblur="validateMandatory(this);" style="border:1px solid black">&nbsp;<FONT color="red">*</FONT></TD>
 </TR>
 <TR>
  <TD>Password</TD>
  <TD><INPUT type="password" name="password"  onblur="validateMandatory(this);" style="border:1px solid black">&nbsp;<FONT color="red">*</FONT></TD>
 <TR>
 <TR>
  <TD>Repeat password</TD>
  <TD><INPUT type="password" name="passcheck"  onblur="validateMandatory(this); validatePasswords()" style="border:1px solid black">&nbsp;<FONT color="red">*</FONT></TD>
 <TR>
 <TR>
  <TD>&nbsp;</TD>
  <TD><INPUT name="submitButton" type="button" value="Register" disabled="true" onclick="submitForm()" style="border:2px solid black"></TD>
 <TR>
</TABLE>
</FORM>
<script>
Benchmark.prototype.setup = function() {
    var form = document.forms[0];
   
};
</script>

Preparation code output

Username  *
Real name  *
Birth date  
Email address  *
Password  *
Repeat password  *
 

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
with out cache
function getInputField(s) {
  for (var i = 0; i < form.length; i++) {
    if (form.elements[i].name == s) {
      return form.elements[i];
    }
  }
}

getInputField("submitButton");
pending…
with cache
function getInputField(s) {
  var el = form.elements;
  for (var i = 0; i < form.length; i++) {
    if (el[i].name == s) {
      return form.elements[i];
    }
  }
}

getInputField("submitButton");
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. Here’s a list of current revisions for this page:

0 comments

Add a comment