-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
6
-
x86
-
windows_2000
A DESCRIPTION OF THE REQUEST :
A profile of an application heavily using String.format revealed that over 90% of the String.format runtime is spent on parsing the format strings. The application uses no more than 10-20 different format strings, each of which are used several million times.
JUSTIFICATION :
If java.util.Formatter could avoid repetitive parsing of format strings, a significant (90% in this case) of runtime could be saved.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Either some sort of PreparedFormatter should be provided that reuses a previously parsed format string, or the Formatter class should cache format strings internally.
ACTUAL -
java.util.Formatter (re)parses format strings for each use.
---------- BEGIN SOURCE ----------
class T {
public static void main (String[] args) {
for (int i = 0;i < 1000000;i++) {
System.out.format ("%d. %s%n",i,"Hello world!");
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None identified.
A profile of an application heavily using String.format revealed that over 90% of the String.format runtime is spent on parsing the format strings. The application uses no more than 10-20 different format strings, each of which are used several million times.
JUSTIFICATION :
If java.util.Formatter could avoid repetitive parsing of format strings, a significant (90% in this case) of runtime could be saved.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Either some sort of PreparedFormatter should be provided that reuses a previously parsed format string, or the Formatter class should cache format strings internally.
ACTUAL -
java.util.Formatter (re)parses format strings for each use.
---------- BEGIN SOURCE ----------
class T {
public static void main (String[] args) {
for (int i = 0;i < 1000000;i++) {
System.out.format ("%d. %s%n",i,"Hello world!");
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None identified.