Extreme tests of JavaScript delete operator

2,636 views
2,518 views

Published on

A series of tests around JavaScript delete operator and memory management on major browser platforms

Published in: Technology, Design
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,636
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Extreme tests of JavaScript delete operator

  1. 1. Extreme tests on the delete operator of JavaScript Wayne Lee, June 2009 http:// trilancer.wordpress.com /
  2. 2. Why <ul><li>Find out various JavaScript Engines’ memory mgmt characteristics </li></ul><ul><li>Understand the importance of delete operator </li></ul>
  3. 3. Approach <ul><li>Plain JavaScript code to </li></ul><ul><ul><li>Add named attributes to Object X </li></ul></ul><ul><ul><li>Then delete them </li></ul></ul><ul><ul><li>Meanwhile, benchmark the time spent </li></ul></ul><ul><ul><li>And memory footprint </li></ul></ul>
  4. 4. 3 Different Test Methods <ul><li>Test A: Add 1 attribute to X, then delete immediately  Repeat 1000s times </li></ul><ul><li>Test B: Bulk add 1000s of attributes, then bulk delete them </li></ul><ul><li>Test C: Bulk add 1000s of attributes, then delete X only </li></ul>
  5. 5. Testing Configuration <ul><li>Windows XP SP3 </li></ul><ul><li>Intel Core Duo 2.16GHz CPU </li></ul><ul><li>2GB RAM </li></ul><ul><li>Internet Explorer 7 </li></ul><ul><li>Firefox 3.0.10 </li></ul><ul><li>Safari 4 (Windows) </li></ul><ul><li>Chrome 2.0 </li></ul><ul><li>Parameter Setting: </li></ul><ul><ul><li>Add 1,000,000 (yes, 1 million) named attributes to an Object X </li></ul></ul>
  6. 6. IE7 <ul><li>A: 221s </li></ul><ul><li>B: 202s </li></ul><ul><li>C: 112s </li></ul>~700MB ~700MB ~70MB
  7. 7. Firefox 3.0.10 <ul><li>A: 5.2s </li></ul><ul><li>B: 6.3s </li></ul><ul><li>C: 3.4s </li></ul>~200MB ~210MB ~70MB
  8. 8. Safari 4 <ul><li>A: 1.5s </li></ul><ul><li>B: 3.9s </li></ul><ul><li>C: 2.1s </li></ul>~230MB ~240MB (flat)
  9. 9. Chrome 2.0.172.30 <ul><li>A: 1.3s </li></ul><ul><li>B: 4.7s </li></ul><ul><li>C: 3.7s </li></ul>~70MB (flat) ~70MB
  10. 10. Show Altogether <ul><li>A </li></ul><ul><li>B </li></ul><ul><li>C </li></ul>IE7 FF3 Safari 4 Chrome 2
  11. 11. <ul><li>Fastest </li></ul><ul><li>Smallest memory footprint </li></ul><ul><li>Most effective GC </li></ul>Preliminary Conclusions Image: http://dezignus.com/prize-icons/
  12. 12. Hints <ul><li>Safari 4, FF3, Chrome 2 are all ideal platforms for complex web apps </li></ul><ul><ul><li>IE7  No </li></ul></ul><ul><ul><li>IE8  Not sure yet </li></ul></ul><ul><li>Explicit delete whenever possible  never assume GC can dramatically collect anything you drop behind </li></ul>
  13. 13. Notes <ul><li>Results NOT gained in “ clean ” environment </li></ul><ul><ul><li>Background processes, browser plugins … </li></ul></ul><ul><li>Memory footprint screenshots from Task Manger </li></ul><ul><ul><li>Inaccurate footprint data </li></ul></ul><ul><ul><li>Maybe influenced by other processes </li></ul></ul><ul><li>IE7 seems OK when adding just 100K (~2s) attributes, and performance drops greatly when it comes to 1M (~200s) </li></ul><ul><li>IE8 not included due to “abnormal” results </li></ul><ul><ul><li>Test A: ~200s </li></ul></ul><ul><ul><li>Test B: ~20s </li></ul></ul><ul><ul><li>Test C: ~12s </li></ul></ul>
  14. 14. Further Tests … <ul><li>Delete variable / attribute: global vs. local </li></ul><ul><li>Safari vs. Firefox on Mac OS </li></ul><ul><li>Page refresh GC test </li></ul><ul><li>Successively tests … </li></ul>
  15. 15. Discussions http://trilancer.wordpress.com/2009/06/10/extreme-testing-of-javascript-delete-operator-on-different-browsers/

×