I made a change in the blogger configuration to ease the later work when blogging. It is possible that older entries are not correctly formatted.

Showing posts with label performance. Show all posts
Showing posts with label performance. Show all posts

Thursday, 3 November 2011

Performance in Java

For diverse purposes I wanted to take a look at performance benchmarks for diverse implementations of collections.

I came to the following free book: Java Performace Book

Moreover, for a project for which I am working we will be do performance measures in order to choose the best infrastructure
for our project. We will do some profiling using JETM or using JProfiler depending on which gives the best infrastructure for our goal.


Thursday, 29 April 2010

Javascript Performance Talk

I watched the javascript performance talk from Nicholas C. Zakas at Google Tech Talks: Nicholas C. Zakas: Speed Up Your JavaScript.

  • Scope Management
  • Loop optimization
  • About HTMLCollection Live objects
  • Document Fragments - postponing reflow

Scope Management

The tip given to improve efficiency is to use local variables, because variables which are in the local scope are accessed first. Every time a global or a variable from a prototype or a dot object variable is accessed twice. Use a local variable.

Another issue related to the scope aspect is that using functions and closures comes with a certain cost.

Loops Optimization

Loops can be optimized in different ways, when avoiding unnecessary work.

About HTMLCollection Live objects

The presentation explains that the collection returned by methods such as: .getElementsByTagName, ... return HTMLCollection objects which remain 'live', that is they get updated. A typical example is the following loop:

var divs = document.getElementsByTagName('div');

for (var i = 0; i< divs.length; i++){
var div = document.createElement('div');
document.body.append(div);
}
The collection in divs is an HTMLCollection. The body of the loops goes over the loops and adds a div for every object in the collection. But since new objects are added to the loop every time one goes through the loops, the loops never ends !!!!!

DocumentFragment - postponing reflow

Reflow occurs when the the size of the elements on the page are recalculated. To improve performance it is useful to minimize the number of reflows.

In general, Nicholas C. Zakas explained that reflow happens at five particular moments in browsers:

  • Page load
  • browser window resize
  • adding and removing elements
  • setting style attribute of elements
  • (sometimes) accessing the style elements of the nodes

To prevent useless reflows, one can use a document fragment in order to create a quite complete element as a document fragment and then add it to the DOM. In this way, reflow is only performed when the element is added to the page.

To minimize the access to the style attributes of elements, a better way to perform that is to change the class of the element, i.e: use .className instead of .style.

Monday, 6 October 2008

Performance according to Martin Fowler

Martin Fowler is well known for his work on refactoring and software engineering. In his very good book: Martin Fowler: patterns of enterprise application architecture. Addison Wesley 2003. he has some discussion of performance which usually cover the following issues:
  • response time
  • responsiveness
  • latency
  • throughput
A number of measures of a system are good indicators for the performance of a system regarding these issues:
  • the load
  • load sensitivity
  • efficiency
  • capacity
To make these notions clear, it is important to have some definition:
response time
the time it take to a system to process a request
responsiveness
the time that the system takes to acknowledge a request
latency
the minimum time that the system needs to perform any task even if the task has nothing to be done
throughput
how much work can be done in a given amount of time
We define the measures presented above:
load
how much strain are put on the resources (for example how many users ( or processes ) are logged on (or running)
load sensitivity
an indicator of the variation in the response time depending on the load
efficiency
the efficiency is the performance (i.e, either throughput or response time) divided by resources
capacity
indicate the maximum effective throughput or load for the system
In order to discuss performance, he also describe two kind of processing power scalability, i.e how good a system reacts when the size of the system grows in processing power. Adding more processing power to a server is an example of vertical scalability (or the system is scaled up), where as adding more servers is an example of horizontal scalability (or the system scales out).