No one is going to give me happiness

I have to go get it on my own.

Oh to remember this every moment of the day, especially a bad day.

The delete operator blows on Firefox 3.0

My friend Brent and I have been refactoring for the next release of the JavaScript API we work on. One of our mini projects made me happy because I knew I would finally have a reason to use JSLitmus. One of the tests we did I believe is worth blogging about.

The scenario is that we currently use a JavaScript Array object to hold a dictionary of callback functions. We index the function in the array with the raw number used to id the request, where the raw number is a random integer from 0 to fucking-gigantic. When the server responds to our request, if there is a callback function associated with the id of the response, then we call the function and null out it’s position in the array.

Essentially:

/* initialize shit */
_callbackArray = [];
/* store shit for later */
_callbackArray[requestId] = functionToCallLater;
/* tell shit to happen */
/* shit happens */
/* catch shit, here responseId === requestId */
if ( _callbackArray[responseId] ) {
_callbackArray[responseId]();
_callbackArray[responseId] = null;
}

Brent and I were curious about:

I decided to test out the second item first. I whipped up a test on JSLitmus to check the speed of our proposed solutions:

What was interesting was how Firefox 3.0.5 on Windows choked like an amateur fluffer when executing a massive number of delete operations. JSLitmus produces cool charts, and I include them for shock value. The graphs are normalized, make sure to pay attention to the numbers (ops per second).

JS Litmus tests of the delete operator on Safari 3.1

JS Litmus tests of the delete operator on Opera 9.5

JS Litmus tests of the delete operator on IE 7

JS Litmus tests of the delete operator on Firefox 3.0

74 deletes per second on Firefox 3.0? It’s like JSLitmus said, “I haz failed ur deletes.” It makes me cry when IE does something better. [Ed: Opera and] Safari are majorly fucking fast, no surprise there. For thoroughness, Brent did some tests on Chrome, and while I didn’t grab the chart off his computer, it appears Chrome is just as handicapable as Firefox when it comes to running delete operations.

Grain of salt: just how many people really need to run tens of thousands of delete ops at a time? No matter the validity of this test, I think the surprise is worthy enough to file a bug with the browsers.

Misdirected Advertising

As part of the new year clean up I logged into Facebook, one of the few social networking sites that I remain a member of. I think they’re telling me I’m getting older.

Misdirected advertising