M
Michael Kreitmann
Hello,
I've a strange performance problem with the follwoing (senseless)
code:
public class XeonTest
{
public static String XMLEncode(String aText)
{
int len = aText.length();
StringBuffer result = new StringBuffer(len);
char ch;
for (int i = 0; i < len; ++i)
{
ch = aText.charAt(i);
result.append(ch);
}
return result.toString();
}
public static void main(String[] args)
{
long start = System.currentTimeMillis();
String s = "The brown fox jumps over the bridge. The brown fox
jumps over the bridge";
String res = "";
for (int i = 0; i < 1000000; ++i)
{
res = XMLEncode(s);
}
System.out.println ("Runtime:" +
(System.currentTimeMillis()-start)+" ms" );
}
}
I'm using java 1.4.2 with the "-server" parameter (but this doesnt'
matters) and Windows 2000 as OS.
Time comparision:
PIII/1000: 5 seconds
2xXeon/1800: 14 seconds
PIV/3000/: 2 seconds
All other performance test on the Xeon machine (SiSoft Sandra) are
runnig good.
Can anybody please give me a hint, what's going wrong here ? All the
time is lost in the "result.append(ch)" line. But why is the Xeon so
slow ?
It would also be great, if anybody could let run the code on any other
Intel Xeon machine ;-)
Many thanks for your help!
Regards
Michael
I've a strange performance problem with the follwoing (senseless)
code:
public class XeonTest
{
public static String XMLEncode(String aText)
{
int len = aText.length();
StringBuffer result = new StringBuffer(len);
char ch;
for (int i = 0; i < len; ++i)
{
ch = aText.charAt(i);
result.append(ch);
}
return result.toString();
}
public static void main(String[] args)
{
long start = System.currentTimeMillis();
String s = "The brown fox jumps over the bridge. The brown fox
jumps over the bridge";
String res = "";
for (int i = 0; i < 1000000; ++i)
{
res = XMLEncode(s);
}
System.out.println ("Runtime:" +
(System.currentTimeMillis()-start)+" ms" );
}
}
I'm using java 1.4.2 with the "-server" parameter (but this doesnt'
matters) and Windows 2000 as OS.
Time comparision:
PIII/1000: 5 seconds
2xXeon/1800: 14 seconds
PIV/3000/: 2 seconds
All other performance test on the Xeon machine (SiSoft Sandra) are
runnig good.
Can anybody please give me a hint, what's going wrong here ? All the
time is lost in the "result.append(ch)" line. But why is the Xeon so
slow ?
It would also be great, if anybody could let run the code on any other
Intel Xeon machine ;-)
Many thanks for your help!
Regards
Michael