Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
Performance Factors and Tuning Tips for JavaScript RIA - - PowerPoint PPT Presentation
PUG Challenge Americas 2011 Performance Factors and Tuning Tips for JavaScript RIA Frameworks Presented by Dustin Grau 6/5/11-6/8/11 Performance Tuning
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
– Page reloads are swapped for many smaller queries – We tend to think smaller == faster, and neglect optimizations
– Server may be bogged by multiple requests, even small ones – An overloaded server can still drag down an AJAX application
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
– “Loading” messages during requests are an interruption – Users should continue work while actions occur transparently
– Varies by user, developer, organization – <1 second is an often-used target – 10ms is fast for an operation, but not if repeated 1,000 x’s
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
– Used Sports2000 DB for benchmarks (orderline table) – All read/write operations used longchar
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
– Connecting - Elapsed time to create a TCP connection – Waiting - Waiting for a response from the server – Receiving - Elapsed time to read entire response
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
– AddOutputFilterByType DEFLATE <mime type> – DeflateCompressionLevel 1
– application/json – application/json-rpc – text/plain – text/html
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
– var myParsedObject = JSON.parse(jsonString);
– Free of HTML and other embedded formatting/tags
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
January 2010
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
April 2011
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
January 2010
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
April 2011
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
January 2010
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
April 2011
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
– Document Object Model (DOM) manipulation – String arrays and innerHTML manipulation
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
January 2010
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
April 2011
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
January 2010
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
April 2011
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
January 2010
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
April 2011
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
– Not possible—client already returned filtered results
– Already tried—client desired all data on a single page
– If it could be determined what rows were being viewed
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
– console.log(object[,object,…]) – console.time(name) – console.timeEnd(name)
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
– Using Console API commands within your code – Setting breakpoints within the plug-in – Using automatic error breaking
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
– http://getfirebug.com/lite.html – Available for IE, Opera, Safari – Limited, but still useful, version of original Firefox plugin
– FireQuery – JQuery debugger – FireCookie – Cookie manager
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
– Tools -> Developer Tools (F12)
– Preferences -> Advanced -> Show Develop menu in toolbar
– View (Wrench Icon) -> Developer -> Developer Tools
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
– http://code.google.com/webtoolkit/speedtracer
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
– jslint.com - JavaScript Code Validator – jsonlint.com - JSON Structure Analyzer
– jslint4java - https://code.google.com/p/jslint4java/ – Combine with Apache ant for automated parsing!
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
– Linux LiveCD based on Knoppix – Available as a Virtual Appliance (VMWare) – Simulates network conditions (speed, packet loss, etc.)
– Web Tools Platform (WTP) and Aptana Plugin – Both offer JavaScript perspective with syntax checking
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
– Table generation was largest portion of processing – JQuery not using native JSON parsing when supported – Data packets contained large amounts of HTML formatting – Flexigrid repeatedly consulted the DOM, did not use variables
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
– Data returned from server was already the quickest action
– Required pre-calculation of the total table height in grid
– Distance from top of DIV gave row position of scroll event
– Rows were only drawn with contents for the viewable area
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
– mod_expires and mod_headers can provide cache control
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡
– Attempt to transparently batch/page data from the server – Download all data, but display only as needed to the user
– Small data requests will be quick, especially multiple requests – Your user has a fast machine, connection, or current browser
Performance ¡Tuning ¡JavaScript ¡RIA’s ¡ BravePoint, ¡Inc. ¡
PUG ¡Challenge ¡Americas ¡2011 ¡
6/5/11-‑6/8/11 ¡