Ajax Performance Analysis
IBM Developerworks' latest was submitted to us by an anonymous reader who writes "Using Firebug and YSlow, you can thoroughly analyze your Web applications to make educated changes to improve performance. This article reviews the latest tools and techniques for managing the performance of Ajax applications along the life cycle of your application, from inception through production."
A good review and counter-argument is available at the "codinghorror" blog where Jeff Atwood points out the codinghorror blogYahoo's Problems Are Not Your Problems
--dave
davecb@spamcop.net
It's actually useful to break the response time out into three parts:
1) Round-trip time, the latency from the network
2) Transfer time, the time from receiving the first byte of the page to the time the last byte arrives. This varies greatly with page size, and is the time you use to do KB/S calculations as well.
3) Latency proper, the time between sending the request and receiving the first byte of the page. This is the time that grows during an overload, and the one that capacity planners use to do queuing models to see how much the server will slow down by under an overload.
--dave (a capcity planner) c-b
davecb@spamcop.net
The author appears to endorse the use of innerHTML as opposed to DOM manipulation.
I suppose it has its place in a performance analysis, but mention might be made that it's just not worth the trading off standards compliance and futureproofing. When I see innerHTML being manipulated I assume the designer didn't know what he was doing.
I recently did a performance analysis of a complex site I've worked on for over a year. My primary tool was Firebug. While the size of the HTML + CSS + JS per page is pretty large, it turns out compressing them and setting header cache only saw a small performance improvement. The execution of JS like Scriptaculous actually accounts for more than 50% of the time it takes to render the pages. Since we only use Scriptaculous for drag-and-drop we're considering alternatives, like mootools or custom code. Loading as much JS as possible from the bottom of the page instead of the head can help, but isn't always an option. Focusing on CSS and JS performance has now made a huge improvement in perceived site performance.
During the initial development we never considered that simply loading one JS library (even when it's not used for inserting HTML) could slow down page rendering that much. On JS or CSS heavy sites, client-side loading, rendering, and runtime execution can easily account for 50% to 90% of the time it takes to see a final page. So while I've usually focused entirely on server side performance, I now know to pay more attention to the speed of client side rendering. Lesson learned.
Developers: We can use your help.
I use AJAX all the time. Firebug is an essential tool for me. It is probably one of my most important web dev tools. You can see all server requests. Even if you don't do AJAX, that is useful. Also, the inspect option on Firebug allows you to make CSS changes without committing to the server. Without Firebug, I'd never be able to have the same insight into my pages.
YSlow is worthless for me. Where I work, I do web development on the intranet. I do not configure the servers, and don't really even have the ability to do so. On the other end, any stuff I might do on the internet will most likely be hosted by some hosting company. Many of the things that YSlow flags are server config items, not *code* items. Sure, that has its place, but if you are a web developer (not a SA) then YSlow gives you a bunch of useless info, then a low grade if your servers are configured a certain way. Ironically, it comes from Yahoo, the masters of the bloated web page. Come to think of it, I should probably get around to uninstalling it instead of just leaving it disabled.
blah blah blah
<html>
<body>
</body>
<script language="javascript">
theDiv = document.createElement("DIV");
theFont = document.createElement("FONT");
theFont.style.fontFamily = "verdana";
theFont.style.fontSize = "24";
theFont.style.fontWeight = "700";
theFont.innerHTML = "Hello World!"
theDiv.appendChild(theFont);
document.body.appendChild(theDiv);
</script>
</html>
Comment removed based on user account deletion
All websites should have an option to run without fancy Javascript (and still be fully functional!). It makes no sense that a web site should bog down my 400Mhz PDA.
Being well aware of the thankless, unforgiving nature of the open web, thanks for the link to the article :-)
Hackers have long memories. It works both ways.
Odd: my 750 MHz box flies on the new system, using a pretty old Mozilla, version 1.7
--dave
davecb@spamcop.net
Ajax Performance Analysis
All I know is, my floors have a nice shine.
The higher the technology, the sharper that two-edged sword.
From what I've seen of the transport tycoon deluxe code dumps, it was written entirely in not particularly efficient assembly...
:( )
(I am a TTDPatch developer)
Writting code in assembly does not equal significant speed or efficiency increase unless you *really* know what you are doing, and are prepared to put a lot of effort into very implementation/processor specific/obscure optimisations (it probably does mean a reduction in code size though, but hardly anyone cares about that these days
Just using a better algorithm and not using bloat libraries or redundant/overdone code will generally improve efficiency more than writing anything in assembly (assuming you write it in C or something along those lines and not a bloat/GC/excessively-OOP language)
Plus assembly is very nonportable, which is generally frowned upon these days for many projects.
There is no psychiatrist in the world like a puppy licking your face - Ben Williams
Talk about making your browser crawl like a turtle, the scripts on that site time out constantly. It's even worse than Yahoo, because at least on Yahoo, the scripts never time out. I have the same issue with Reddit and other such sites. Not everyone has 10+ mbit connections running on Quad-Core machines with 4 GB of RAM. Web devs seem to forget this more than any other programmer class. Just because it runs fine on your 100+ mbit connection and Intel Mac at work, doesn't mean it runs that way anywhere else.
:)
Funny thing: If I totally disable JS, then the sites load up REALLY fast, I just can't do anything like reply to comments
@Mindless Drivel: 100% of Twitter posts ever Tweeted.
While I love Firebug and use it daily for web development, you shouldn't trust its net tab too much. I've found in numerous instances it has grossly understated load times, for example loading a very PHP heavy page which Firebug claimed was loading in 13ms, however serverside performance testing showed that the load time was actually over 1 second. I've actually found Safari's new Web Inspector tools to be much more accurate in this regard so I'd recommend using them for performance testing if you suspect Firebug isn't telling you everything.
I'm a bit of a noob to AJAX, but/and getting good performance on data-heavy AJAX pages has been a real challenge. I'm specifically working on a data grid with 1000+ rows using Ext. I've gotten it to be acceptable via techniques like behind-scenes paging, direct innerHTML modification instead of relying on library grid redraws, etc etc. I haven't tried simply rendering the grid with XML->XSLT, though (the grid widget is awful nice ...)
It's probably unrealistic to want a web page to present a christmas-tree grid with this much data but a guy can dream can't he?
I've also noticed that JSON eval() calls are tremendously CPU intensive in IE (as opposed to FF) -- perhaps IE likes XML better? (Didn't innerHTML come from M$ in the first place?)
I do agree that C++ is going to get a big resurgence as people are going to start looking for faster ways to execute their applications (and AJAX calls) and while scripting is adequate for low volume, once the volume of users goes up you really want the server to be the least of their concerns and concentrate on speeding up the network, database, etc.
AJAX makes a lot of little calls back to the server and it is critical that they are processed very quickly to give the site a responsive appearance, there is an appreciable difference between an ajax server response of 10ms compared to 50ms (after you factor in the network latency, bandwidth, jitter and other network issues).
I'm hoping C++ comes back faster, I am disliking java more and more every day. I hate the long build times, long deploy to tomcat times and long startup times; I waste more time now waiting to verify/debug/enhance than I ever did with C++. My browsing and slashdot posting skills did go up since I do more of it now while I wait.