Posts Tagged ‘Performance’

Installing mod_pagespeed on Ubuntu

Wednesday, June 8th, 2011

mod_pagespeed is an Apache HTTP module which is supposed to do a lot of website performance optimization before sending it to the browser. For details please check mod_pagespeed docs or the Google IO talk (Make the web faster) about this topic.

Installing on Ubuntu is simple, please see Download site and explanation. Please note that the example below uses the 64bit version.

wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-beta_current_amd64.deb
dpkg -i mod-pagespeed-*.deb
apt-get -f install

This will add the Google repository to your system so an apt-get update & upgrade will keep mod_pagespeed up to date.

A quick check with http://www.webpagetest.org showed that it speeds up vogella.de significantly. I used my Android tutorial as example.

Without the module:

  Load Time  First Byte   Start Render 
First View   13.417s   0.385s   1.377s  
Repeat View   3.006s   0.380s   0.766s  

With the module activated:

  Load Time  First Byte   Start Render 
First View   8.980s   0.380s   1.270s  
Repeat View   2.441s   0.389s   0.792s  

Pretty cool performance improvements for 5 minutes of installation effort. :-)

Thanks to Google for making the web faster. I hope this module gets contributed to the Apache HTTP server.

Android – Making efficient layouts

Monday, March 7th, 2011

Android Programming is a lot about efficiency to have snappy user interfaces. The Android SDK provides two nice tools to help building efficient UI’s. In the tools directory you find the tools:

layoutopt and
hierarchyviewer.

layoutopt is a command line tool which can analyse a layout resource file and tell you what is not required and hierarchyviewer is a tool to view the View hierarchy of your running application.

I suggest to have a look at these tools and check your layouts especially if you have created a complex application.

Profiling Eclipse RCP applications with Eclipse TPTP

Wednesday, November 18th, 2009

I believe approx. one or two years ago I tried to profile an Eclipse RCP application with the Eclipse TPTP project. I believe at this point in time profiling an RCP application with TPTP was not possible.

I learned from Eugene Chan that the TPTP release which is part of Eclipse Galileo allows to profile Eclipse RCP applications.

I suggest you give it a try, it is as easy as profiling a standard ;-) Java application.

You find an updated description here: Eclipse TPTP Tutorial.

Thanks to Eugene Chan, Paul Slauenwhite and Kathy Chan from the TPTP team for feedback on the article.

Java Performance with Strings and StringBuilder

Sunday, July 19th, 2009

Strings are very frequently used in Java programs. This blog post tries to explain what a programmer needs to consider from a performance point of view. It will also explain in what situations you should use StringBuilder instead of String.

Strings in Java are immutable. If you look at the source code of String you find that java.lang.String has the following properties.

/** The value is used for character storage. */
    private final char value[];

 /** The offset is the first index of the storage that is used. */
    private final int offset;

 /** The count is the number of characters in the String. */
    private final int count;

The array is used to store the values of this String.

As Strings are immutable they can be freely shared. This property is utilized in the method substring(). The method substring will use a reference to the same String and only change the offset and the lenght value for the String. The same string is in this case used several times.

Therefore using substring requires only a constant amount of time (and almost no additional memory) and can be freely used.

The operation concat() (which is called by the + operator) combines two Strings. This method has to copy the characters of the two Strings and therefore takes time and extra space which is propotional to the length of the two strings .

The object StringBuilder has a more effectly way of concatenate Strings. It works similar to the class ArrayList by allocating a predefined array for storing the characters and keeps track of the used space. Every time the space is exceeded then it will extend the available capacity).

Does this means that you always have to use StringBuilder if you are concatening strings?

No. Of course if in your program you combine only a few times String the runtime overhead is normally not relevant for the overall performance.

But of course if you combine frequently strings in your program you should switch to StringBuilder.


Switch to our mobile site