Pages
Categories
Archives
JsTweeterManiac
- #nodejs google plus fan page just crossed 1000 followers! http://t.co/IdbGqaXd 4 days ago
- #nodejs google plus fan page just crossed 800 followers http://t.co/IdbGqaXd ! 2 weeks ago
- hey @ryah {http://t.co/fdc8SCPR} you've done some cool stuff, I'm a fan via {http://t.co/2NPs9fNA} 2 weeks ago
- node.js makes programming fun again https://t.co/qgZwpOzL 3 weeks ago
- core #nodejs in #coffeescript? How about debugging this? http://t.co/iICMV30r 1 month ago
- 1999:Java - is for small projects,use C. 2005:Ruby - is for small projects,use Java. 2011:node.js - is for small projects, use Ruby for big 1 month ago
- >npm xmas 1 month ago
- WebStorm 3 officially out. With #nodejs and #coffeescriptsupport http://t.co/kCrF8Ba4 1 month ago
- Behold of #eval fanpage join #javascript #evil legions! https://t.co/9b2NotMs 1 month ago
- Position: fixed revisited http://t.co/jJ0fPsoy 1 month ago
-
RSS Links
-
Meta
Javascript performance summary
I have an idea that Javascript could allow us to improve perfomance of our web applications. Of cause JS is very slow but unlike server side code we can run it on side of our clients. Something like client side cloud-computing.
It is jut an idea… for now.
Thing i can do right now is to improve performance of my scripts as much as possible. A lot can be gained just by following some coding style rules.
Javascript performance. Array vs Object
Reading and writing perfomance is not differs too much for this two. So you can easily use Object for mapping purposes and Array for unordered stuff.
details:
I have coded a simple profiler to test some siple pieces of code. Here it is:
function Profile(){ } Profile.prototype.status = 0;//0 free, 1 busy Profile.prototype.tests = []; Profile.prototype.testIt = function(){ if (!this.status && this.tests.length > 0) { var atest = this.tests.shift(); var that = this; var l = setTimeout(function(){ that.process(atest[0], atest[1], atest[2]); that.testIt(); }, 500); this.status = 1; } } Profile.prototype.profile = function(func, name, before){ Profile.prototype.tests.push([func, name, before]); this.testIt(); } Profile.prototype.process = function(func, name, before){ var AVGtime = 0; for (var i = 0; i < 20; i++) { var scope = {}; before.call(scope); var dbefore = new Date(); func.call(scope); var dafter = new Date(); AVGtime += dafter.getTime() - dbefore.getTime(); } this.report(func, AVGtime / 20, name); this.status = 0; } Profile.prototype.report = function(func, avg, name){ var funcDiv = document.createElement("div"); var report = "<div class='function' style='font-size: small; border: 1px solid #999; margin: 10px 0 3px 10px; padding: 5px;'>" + func.toString() + "</div"; report += "<div class='avgTime' style='font-weight: bold;margin: 0 0 0 10px'>" + name + ": " + avg + "ms</div>"; funcDiv.innerHTML = report; document.body.appendChild(funcDiv); }Here are the rules and results of all perfomance tests i run.
Javascript performance. Array vs Object