wiki:Performance/Client

All figures taken with Firefox 2.0.0.12 and Firebug.

Webmore refreshing

Webmore.refresh function performs the following operations:

  1. Sentence activation. span.webmore_sentence elements queried, for each Sentence object created, and activate method called. activate registers event listeners for each sentence span. Each object creation costs about 0.5 ms and activate call — about 1 ms. So a total of 1,5 ms per sentence, or about 300 ms per 1000 English words in average political text :-)
  2. Bubble positioning (Webmore.redraw). This function loops through each anchor and is executed twice per refresh. Average loop body execution time is 40 ms. About 2/3 of this time takes Element.down function, which is called 3-4 times per loop body and each call takes about 7-8 ms.
  3. reset_vlines and fill functions, execution time negligible even for very bloated page.
  4. Event registration.
    1. For comment action links: about 10 ms per link. Each expanded comment of current user has 2 or 4 links.
    2. For all expanded comments: about 1 ms per comment.
    3. For all bubbles: about 0.3 ms per bubble.

Initial article page load

refresh function is executed twice. LOTS of time on heavily commented page, Firefox from time to time prompts to kill script.

For example, take page with:

  • 309 sentences (total content length 13 KB)
  • 60 anchors
  • 120 bubbles
function calls total time
Webmore.load 1 14.4 sec
Webmore.redraw 4 13.3 sec
redraw main loop body 240 13.2 sec
Webmore.register_events 2 185 ms
Sentence.initialize 618 138 ms
Sentence.activate 618 564 ms
_getElementsByXPath (prototype.js) 1266 9.2 sec

Bubble expansion

  1. Request root anchor (getRoot). about 15 ms per level.
  2. Get root descendants and query their state (expandedDescendants): about 30 ms per expanded comment.
  3. Request anchor tree from server. See [Performance/Server] for details.
  4. Receive answer, replace bubble text, and refresh webmore. Here is spent most of time.

Bubble collapse

Basically, the same steps as for expansion, just current bubble is removed from array of expanded ones. So, timings are pretty much the same.

Commenting, comment editing, approving comment, viewing valid parent

WCB appears in no time, good enough :-)

Any activity besides request to server, and subsequent webmore refresh is negligible, completing in under 50 ms regardless of page state.