-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.2
-
generic, x86
-
generic, linux
Name: gm110360 Date: 04/08/2003
FULL PRODUCT VERSION :
JDK 1.3.1_07, JDK 1.4.1 JDK 1.4.2Beta
FULL OS VERSION :
Linux agentdev 2.4.18-27.8.0 #1 Fri Mar 14 06:45:49 EST 2003 i686 i686 i386 GNU/Linux
Also in win32 platforms
EXTRA RELEVANT SYSTEM CONFIGURATION :
PIII 933MHz, 384MB RAM
A DESCRIPTION OF THE PROBLEM :
There is a poor performance on:
HashMap, StringBuffer, System.arraycopy
JDK 1.4.1 (1.4.2 is even worse) is 2 times slower on those types of operations
than 1.3.1
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just write a program that inserts/looks up stuff from HashMap or does operations
(.append()) with StringBuffer or performs System.arraycopy().
EXPECTED VERSUS ACTUAL BEHAVIOR :
System.arraycopy: 72ms
System.arraycopy: 249ms
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.lang.reflect.*;
public class test
{
/**
* The source array
*/
static final char[] a = {'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', '!'};
/**
* The target array
*/
static final char[] b = new char[a.length];
/**
* The simple method invoked using reflection
*/
public static int f()
{
return 5;
}
/**
* The StringBuffer test method
*/
public static String fSB()
{
StringBuffer buff = new StringBuffer(12);
buff.append("Hello");
buff.append(' ');
buff.append("World");
buff.append('!');
return buff.toString();
}
/**
* Invokes this method
*
* @param param The first parameter
* @param param2 The second parameter
*
* @return int - Number
*
* @exception NullPointerException Never thrown
*/
public static int fSB0(int param, int param2) throws NullPointerException
{
System.arraycopy(a, 0, b, 0, a.length);
return 0;
}
/**
* The main
*
* @param args The arguments
*/
public static void main(String[] args)
{
System.out.println("Tests performed on " + System.getProperty("java.version"));
System.out.println(" " + System.getProperty("java.vm.vendor"));
System.out.println(" " + System.getProperty("java.vm.name"));
try
{
Class aClass = Class.forName("test");
Method m = aClass.getMethod("f", null);
long start = System.currentTimeMillis();
for(int i = 0; i < 1000000; i++)
{
m.invoke(null, null);
}
long end = System.currentTimeMillis();
System.out.println("Reflection: " + (end - start));
start = System.currentTimeMillis();
for(int i = 0; i < 1000000; i++)
{
String s = fSB();
}
end = System.currentTimeMillis();
System.out.println("String Buffer: " + (end - start));
start = System.currentTimeMillis();
for(int i = 0; i < 1000000; i++)
{
fSB0(0, 1);
}
end = System.currentTimeMillis();
System.out.println("System.arraycopy: " + (end - start));
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
Release Regression From : 1.3.1
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
(Review ID: 183695)
======================================================================
- duplicates
-
JDK-4809502 Faster System.arraycopy
-
- Resolved
-