Re: performance improving tactics vs. optimizer.
- From: Lew <lew@xxxxxxxxxxxxx>
- Date: Sun, 13 Apr 2008 08:48:17 -0400
Roedy Green wrote:
see http://mindprod.com/project/stringbuilderoptimiser.html
from which:
Convert sb.append ( " " ) to sb.append ( ' ' );
This might not be much of an optimization. The String " " is literal, and therefore will be obtained directly from the intern pool. HotSpot will see an indirect reference to the same location in the JVM for the argument of each 'append(" ")'. That's only one hop longer than a direct load of the character. Part of the student project (excellent service to the community to post those projects, btw) should be to benchmark the difference between the String- and character-argument calls before implementing the optimization, and to compare any change in the String-argument call times to that difference as well.
Just to invent fictional numbers by way of example, let's say the String benchmark time is two granoseconds ("grano-" being the prefix for whatever is the appropriate granularity of measurement), and the character time is one granosec. One would hope that the optimized String call would come down from 2 granosec to something close to one. Also, if you happen to test on a JVM whose authors have already optimized the String call, you might find that the "before" difference is surprisingly small. Maybe the difference without your optimization is only 1.001 granosec for the String call vs. one for the character case, once HotSpot warms up.
--
Lew
.
- Follow-Ups:
- Re: performance improving tactics vs. optimizer.
- From: Roedy Green
- Re: performance improving tactics vs. optimizer.
- References:
- How much efficient is Java 6 to Java 1.3?
- From: Sanny
- Re: How much efficient is Java 6 to Java 1.3?
- From: Joshua Cranmer
- Re: How much efficient is Java 6 to Java 1.3?
- From: jolz
- Re: How much efficient is Java 6 to Java 1.3?
- From: Lew
- Re: How much efficient is Java 6 to Java 1.3?
- From: jolz
- Re: How much efficient is Java 6 to Java 1.3?
- From: Arne Vajhøj
- Re: How much efficient is Java 6 to Java 1.3?
- From: Roedy Green
- performance improving tactics vs. optimizer. (was: Re: How much efficient is Java 6 to Java 1.3?)
- From: Andreas Leitgeb
- Re: performance improving tactics vs. optimizer. (was: Re: How much efficient is Java 6 to Java 1.3?)
- From: Roedy Green
- Re: performance improving tactics vs. optimizer. (was: Re: How much efficient is Java 6 to Java 1.3?)
- From: Andreas Leitgeb
- How much efficient is Java 6 to Java 1.3?
- Prev by Date: How to Choose an Unlimited Web Hosting for free
- Next by Date: Which class is better for reading binary data?
- Previous by thread: Re: performance improving tactics vs. optimizer. (was: Re: How much efficient is Java 6 to Java 1.3?)
- Next by thread: Re: performance improving tactics vs. optimizer.
- Index(es):
Relevant Pages
|