Skip to main content

java.beans.XMLEncoder performace degradation in JDK 7?

No replies
twsharp
Offline
Joined: 2009-04-01

Test the following code with JDK 6 and JDK 7.
In my machine, the results are as follows.
JDK 1.6.0_17: about 1.5 seconds
JDK 1.7.0-ea-b76: about 22 seconds

import java.beans.XMLEncoder;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JButton;

public class TestXMLEncoder {

public static void main(String[] args) throws IOException {
List list = new ArrayList();
for (int i = 0; i < 1000; i++) {
list.add(new JButton("Hello, world"));
}
XMLEncoder e = new XMLEncoder(new BufferedOutputStream(
new FileOutputStream("Test.xml")));
long start = System.currentTimeMillis();
e.writeObject(list);
e.close();
long end = System.currentTimeMillis();
System.out.println(end - start);
}

}