Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#8034 closed enhancement (fixed)

use dojo.delegate(... instead of dojo.mixin(dojo.clone(... for attributeMaps

Reported by: alex Owned by: alex
Priority: low Milestone: 1.3
Component: Dijit Version: 1.2.0
Keywords: dijit, delegate, mixin, clone Cc:
Blocked By: Blocking:

Description

today, many attribute map properties are specified like this:

    attributeMap: dojo.mixin(dojo.clone(dijit.form._FormWidget.prototype.attributeMap), {
        label: {node: "containerNode", type: "innerHTML" },
        iconClass: {node: "iconNode", type: "class" }
    }),

but could be more efficiently defined as:

    attributeMap: dojo.delegate(dijit.form._FormWidget.prototype.attributeMap, {
        label: {node: "containerNode", type: "innerHTML" },
        iconClass: {node: "iconNode", type: "class" }
    }),

We should make this change globally.

Attachments (1)

load.html (2.3 KB) - added by bill 10 years ago.
script to time defining all the widgets (but not instantiating any)

Download all attachments as: .zip

Change History (4)

comment:1 Changed 11 years ago by alex

...and here's the list:

obelisk:dijit alex$ ack -l "dojo.mixin\(dojo.clone"
Dialog.js
form/_FormWidget.js
form/Button.js
form/Form.js
form/MultiSelect.js
form/SimpleTextarea.js
form/Slider.js
form/Textarea.js
form/TextBox.js
layout/AccordionContainer.js
Menu.js
TitlePane.js

comment:2 Changed 11 years ago by alex

Resolution: fixed
Status: newclosed

fixed in [15618]

comment:3 Changed 10 years ago by bill

The problem with this change is that while it theoretically speeds up widget declarations (the time it takes for the dojo.declare() to execute), it theoretically slows down widget instantiation (new dijit.form.Button()), because attributeMap now has a prototype chain (Button --> FormWidget --> _Widget).

I tried running some benchmarks, both with a page that merely loads all the widgets (load.html), and on benchTool.html, timing the creation of 100 button widgets:

Before [15618]:

  • load.html:
    • IE8: 78, 93, 62, 78
    • IE6: 109, 109, 141
  • benchTool.html:
    • IE8: 500, 515, 547, 562, 610
    • IE6: 687, 750, 828, 938, 1000, 1125
    • FF3.5: 247, 259, 160

After [15618] :

  • load.html on IE8: 78, 78, 78, 62, 62, 78
  • benchTool.html:
    • IE8: 484, 516, 531, 563, 594
    • IE6: 828, 750, 859, 907, 1172, 1110, 1188
    • FF3.5: 242, 244, 260

The numbers are all over but I don't see any clear pattern. I guess the change just isn't significant one way or the other.

Changed 10 years ago by bill

Attachment: load.html added

script to time defining all the widgets (but not instantiating any)

Note: See TracTickets for help on using tickets.