datepicker setDate extremely slow
Hi,
I just did some experiments with the datepicker and discovered that
the setDate and options functions are extremely slow.
When I do a datepicker create, call the getDate function and destroy
the datepicker widget, it takes about 6ms (IE8) / 2ms (FF3).
The same with a setDate or set option instead of the getDate takes
296ms (IE8) / 65ms (FF3) and 299ms (IE8) / 60ms (FF3), respectively.
So the setDate function is roughly 50 times slower than getDate for
IE8. I understand that there are input validations for the setDate
function, but that would be nearly 300ms of date validation?
Is there any trick to speed up the set-up of a datepicker (create and
set start date)?
Another interesting point is, that setting the options during creation
( xxx.datepicker({x:y}) ) seams to have no impact on the runtime,
while setting options with xxx.datepicker("option",{x:y}) takes very
long.
by(e)
Stephan
my testscript:
<script type="text/javascript">
$(function() {
el = $("<input/>").appendTo("body");
var ticks = new Date();
for (var i=0; i<20; i++) {
el.datepicker({showWeeks: true});
el.datepicker("destroy");
}
var ticks = ((new Date())-ticks)/i;
$("datepicker (create/destroy): "+ticks+" ms
").appendTo("body");
var ticks = new Date();
for (var i=0; i<20; i++) {
el.datepicker();
el.datepicker("getDate");
el.datepicker("destroy");
}
var ticks = ((new Date())-ticks)/i;
$("datepicker (create/getDate/destroy): "+ticks+" ms
").appendTo("body");
var ticks = new Date();
for (var i=0; i<20; i++) {
el.datepicker();
el.datepicker("setDate", new Date());
el.datepicker("destroy");
}
var ticks = ((new Date())-ticks)/i;
$("datepicker (create/setDate/destroy): "+ticks+" ms
").appendTo("body");
var ticks = new Date();
for (var i=0; i<20; i++) {
el.datepicker();
el.datepicker("option",{showWeeks: true});
el.datepicker("destroy");
}
var ticks = ((new Date())-ticks)/i;
$("datepicker (create/option/destroy): "+ticks+" ms
").appendTo("body");
});
</script>