Login Register

NumberTextBox is slow in Dojo 1.2

NumberTextBox (or perhaps some RegEx-stuff) is extremly slow in the new Dojo version 1.2:

I simple test tells the facts, this is the performance-timings in IE7:
Dojo version 1.2.0 (15385)
Time 1: Reset form with NumberTextBox-fields: 500 millis
Time 2: Reset form with ValidationTextBox-fields: 109 millis
Time 3: Inserting value into NumberTextBox-fields: 938 millis
Time 4: Inserting value into ValidationTextBox-fields: 93 millis

Dojo version 1.1.1 (13707)
Time 1: Reset form with NumberTextBox-fields: 79 millis
Time 2: Reset form with ValidationTextBox-fields: 31 millis
Time 3: Inserting value into NumberTextBox-fields: 125 millis
Time 4: Inserting value into ValidationTextBox-fields: 31 millis

The performance is relativily poor in Firefox too:
Dojo version 1.2.0 (15385)
Time 1: Reset form with NumberTextBox-fields: 301 millis
Time 2: Reset form with ValidationTextBox-fields: 30 millis
Time 3: Inserting value into NumberTextBox-fields: 334 millis
Time 4: Inserting value into ValidationTextBox-fields: 32 millis

Dojo version 1.1.1 (13707)
Time 1: Reset form with NumberTextBox-fields: 26 millis
Time 2: Reset form with ValidationTextBox-fields: 11 millis
Time 3: Inserting value into NumberTextBox-fields: 46 millis
Time 4: Inserting value into ValidationTextBox-fields: 14 millis

Here is the JavaScript-code:

function performancetest() {
        console.log("Dojo version " + dojo.version);
        var startTime1 = (new Date()).getTime();
        dijit.byId("form1").reset();
        console.log("Time 1: Reset form with NumberTextBox-fields: " + ((new Date()).getTime() - startTime1) + " millis");
        
        var startTime2 = (new Date()).getTime();
        dijit.byId("form2").reset();
        console.log("Time 2: Reset form with ValidationTextBox-fields: " + ((new Date()).getTime() - startTime2) + " millis");
        
        var startTime3 = (new Date()).getTime();
        for (var i = 1; i <= 20; i++) {
			    var w = dijit.byId("input1_" + i);
			    if(dojo.version.major == 1 && dojo.version.minor == 2) {
			      w.attr("value", i);
			    } else {
			      w.setValue(i);
			    }
			  }
        console.log("Time 3: Inserting value into NumberTextBox-fields: " + ((new Date()).getTime() - startTime3) + " millis");
        
        var startTime4 = (new Date()).getTime();
        for (var i = 1; i <= 20; i++) {
			    var w = dijit.byId("input2_" + i);
			    if(dojo.version.major == 1 && dojo.version.minor == 2) {
			      w.attr("value", i);
			    } else {
			      w.setValue(i);
			    }
			  }
        console.log("Time 4: Inserting value into ValidationTextBox-fields: " + ((new Date()).getTime() - startTime4) + " millis");
      }

and here is the main html-code:

<form id="form1" dojoType="dijit.form.Form" action="" method="">
      <input id="input1_1" name="input1" maxLength="6" type="text" dojoType="dijit.form.NumberTextBox"/>
      <input id="input1_2" name="input1" maxLength="6" type="text" dojoType="dijit.form.NumberTextBox"/>
      <input id="input1_3" name="input1" maxLength="6" type="text" dojoType="dijit.form.NumberTextBox"/>
      <input id="input1_4" name="input1" maxLength="6" type="text" dojoType="dijit.form.NumberTextBox"/>
      <input id="input1_5" name="input1" maxLength="6" type="text" dojoType="dijit.form.NumberTextBox"/>
      <input id="input1_6" name="input1" maxLength="6" type="text" dojoType="dijit.form.NumberTextBox"/>
      <input id="input1_7" name="input1" maxLength="6" type="text" dojoType="dijit.form.NumberTextBox"/>
      <input id="input1_8" name="input1" maxLength="6" type="text" dojoType="dijit.form.NumberTextBox"/>
      <input id="input1_9" name="input1" maxLength="6" type="text" dojoType="dijit.form.NumberTextBox"/>
      <input id="input1_10" name="input1" maxLength="6" type="text" dojoType="dijit.form.NumberTextBox"/>
      <input id="input1_11" name="input1" maxLength="6" type="text" dojoType="dijit.form.NumberTextBox"/>
      <input id="input1_12" name="input1" maxLength="6" type="text" dojoType="dijit.form.NumberTextBox"/>
      <input id="input1_13" name="input1" maxLength="6" type="text" dojoType="dijit.form.NumberTextBox"/>
      <input id="input1_14" name="input1" maxLength="6" type="text" dojoType="dijit.form.NumberTextBox"/>
      <input id="input1_15" name="input1" maxLength="6" type="text" dojoType="dijit.form.NumberTextBox"/>
      <input id="input1_16" name="input1" maxLength="6" type="text" dojoType="dijit.form.NumberTextBox"/>
      <input id="input1_17" name="input1" maxLength="6" type="text" dojoType="dijit.form.NumberTextBox"/>
      <input id="input1_18" name="input1" maxLength="6" type="text" dojoType="dijit.form.NumberTextBox"/>
      <input id="input1_19" name="input1" maxLength="6" type="text" dojoType="dijit.form.NumberTextBox"/>
      <input id="input1_20" name="input1" maxLength="6" type="text" dojoType="dijit.form.NumberTextBox"/>
      </form>
     
      <form id="form2" dojoType="dijit.form.Form" action="" method="">
      <input id="input2_1" name="input1" maxLength="6" type="text" dojoType="dijit.form.ValidationTextBox"/>
      <input id="input2_2" name="input1" maxLength="6" type="text" dojoType="dijit.form.ValidationTextBox"/>
      <input id="input2_3" name="input1" maxLength="6" type="text" dojoType="dijit.form.ValidationTextBox"/>
      <input id="input2_4" name="input1" maxLength="6" type="text" dojoType="dijit.form.ValidationTextBox"/>
      <input id="input2_5" name="input1" maxLength="6" type="text" dojoType="dijit.form.ValidationTextBox"/>
      <input id="input2_6" name="input1" maxLength="6" type="text" dojoType="dijit.form.ValidationTextBox"/>
      <input id="input2_7" name="input1" maxLength="6" type="text" dojoType="dijit.form.ValidationTextBox"/>
      <input id="input2_8" name="input1" maxLength="6" type="text" dojoType="dijit.form.ValidationTextBox"/>
      <input id="input2_9" name="input1" maxLength="6" type="text" dojoType="dijit.form.ValidationTextBox"/>
      <input id="input2_10" name="input1" maxLength="6" type="text" dojoType="dijit.form.ValidationTextBox"/>
      <input id="input2_11" name="input1" maxLength="6" type="text" dojoType="dijit.form.ValidationTextBox"/>
      <input id="input2_12" name="input1" maxLength="6" type="text" dojoType="dijit.form.ValidationTextBox"/>
      <input id="input2_13" name="input1" maxLength="6" type="text" dojoType="dijit.form.ValidationTextBox"/>
      <input id="input2_14" name="input1" maxLength="6" type="text" dojoType="dijit.form.ValidationTextBox"/>
      <input id="input2_15" name="input1" maxLength="6" type="text" dojoType="dijit.form.ValidationTextBox"/>
      <input id="input2_16" name="input1" maxLength="6" type="text" dojoType="dijit.form.ValidationTextBox"/>
      <input id="input2_17" name="input1" maxLength="6" type="text" dojoType="dijit.form.ValidationTextBox"/>
      <input id="input2_18" name="input1" maxLength="6" type="text" dojoType="dijit.form.ValidationTextBox"/>
      <input id="input2_19" name="input1" maxLength="6" type="text" dojoType="dijit.form.ValidationTextBox"/>
      <input id="input2_20" name="input1" maxLength="6" type="text" dojoType="dijit.form.ValidationTextBox"/>
      </form>
     
      <button name="button" onclick="performancetest()">Run tests</button>

(I can email the complete source-file by request).

The profiler in Firebug shows that buildGroupRE in regexp.js is called 15480 times for dojo 1.2 compared to 1080 times in dojo 1.1.1.

Any comments on this?

Kind regards
Stein M

The source

Re: The source

Sorry, but the lame hostingcompany injected ads into the html source-file, so here is the source-file zipped:
http://home.no.net/dulci/test_numbertextbox_performance.zip

Re: NumberTextBox is slow in Dojo 1.2