Hello Martin, As a follow-up to our performance discussion, here are a few new figures that put the differences between MessageFormatter and String.format() in perspective with a typical log to a file.
We are logging to a file on the local host, with a simple PatternLayout. With 1 parameter: MessageFormatter 11 microseconds String.format 24 microseconds With 3 parameters: MessageFormatter 13 microseconds String.format 30 microseconds With 0 parameters: MessageFormatter 9 microseconds String.format 11 microseconds I've simply replaced the code inside MessageFormatter's arrayFormat method with a call to String.format(), so that there is no difference in the calls sequence. We can see that the difference stays important. Seeing these values, I think that we should not use the String.format method instead of the MessageFormatter class. This question was raised in the previous discussions about this subject, and these tests give a clear view of the best choice, I think. In one of your previous messages, you mentionned the StopWatch that you used to measure the values. Based on this class' javadoc[1], it calls the System.currentTimeMillis() method to measure time. The System.nanoTime() method is much more precise and constant than System.currentTimeMillis(). You might expect more constant result using it rather than the StopWatch, unless you're under jdk 1.4, where the System.nanoTime() method does not exist. Cheers, Sébastien [1]http://www.springframework.org/docs/api/org/springframework/util/StopWatch.html Sebastien Pennec wrote: > Martin, > > Sorry for the misreading of your code. > > Measuring a complete log is actually a good idea. I was pointing this > because you > mentioned that you had trouble obtaining consistent results, which I had not > using > my code. This and the first "dry" run were the two main differences between > your code > and mine. > > Cheers, > > Sébastien > -- Sébastien Pennec [EMAIL PROTECTED] Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch/ _______________________________________________ user mailing list [email protected] http://www.slf4j.org/mailman/listinfo/user
