Extreme testing of JavaScript delete operator on different browsers

When designing JPolite 2, I felt the need to do some memory management testing, especially about the delete operator. So I made a little piece of test page to illustrate the effect of delete on memory occupation of different browsers (as well as the performance of built-in JavaScript engines).

The approach is simple: add named attributes to an object X and then delete them. Benchmark the time spent, and memory footprint meanwhile. Three different test methods are used:

  • A. Add 1 attribute to X, then delete immediately  <– Repeat 1000s times
  • B. Bulk add 1000s of attributes, then bulk delete them
  • C. Bulk add 1000s of attributes, then delete X only

The tests were performed on Windows XP SP3, Intel Core Duo 2.16GHz CPU, 2GB RAM. IE7, FF3, Safari 4 and Chrome 2.0 were used in the test. No framework used at all, just plain simple JavaScript code.

Sample test code can be found here: http://www.trilancer.com/extreme_delete.html

Some interesting results are gained that Safari 4 seems to be the fastest browser as Apple claimed, though Chrome 2 runs a little bit faster than Safari 4 in Test A. Chrome 2’s memory utilization seems to be the most efficient since it occupies least memory footprints. Firefox’sGC seems the best, which can always reclaim garbage in time. And IE7 is the slowest, whose performance drops dramatically when the number of attributes changes from 100K(~2.7s) to 1M(~200s). Funny thing is that, seems IE7 can eventually reclaim most of the garbage, where Safari & Chrome can not 🙂

Anyway, I’m in essence a front-end developer not a professional tester. Just went some extra miles on JS language and engine this time. However, I do hope my work can help you gain some more understanding of JavaScript and pros and cons of various browsers 😀


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s