You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "deven you (JIRA)" <ji...@apache.org> on 2010/09/28 09:03:32 UTC

[jira] Commented: (HARMONY-6664) [classlib][beans] Poor performance of java.beans.XMLEncoder.writeObject() method

    [ https://issues.apache.org/jira/browse/HARMONY-6664?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12915648#action_12915648 ] 

deven you commented on HARMONY-6664:
------------------------------------

I have profiled this test case, and the result shows java.beans.ReferenceMap is the hottest method. When I Looked into this class, I found it uses a array to store a key value pair so the cost time if O(n) level. If we use some kind of Hash table it can reduce to O(1) level. I think it would increase the performance a lot.

> [classlib][beans] Poor performance of java.beans.XMLEncoder.writeObject() method
> --------------------------------------------------------------------------------
>
>                 Key: HARMONY-6664
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6664
>             Project: Harmony
>          Issue Type: Task
>          Components: Classlib
>    Affects Versions: 5.0M15
>            Reporter: Kevin Zhou
>            Assignee: Kevin Zhou
>             Fix For: 6.0M4
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> Given a test case [1], the performance of java.beans.XMLEncoder.writeObject() is very poor.
> ***************INDEX=5*****************************
> writing 5000 of integers	encode time:2025	flush time:40
> writing 10000 of integers	encode time:6242	flush time:87
> writing 15000 of integers	encode time:12464	flush time:137
> writing 20000 of integers	encode time:21949	flush time:166
> writing 25000 of integers	encode time:32119	flush time:219
> For writing a list of 25000 integers, XMLEncoder.writeObject() takes about half a minute.
> [1] Performance test case:
> public class XMLEncoderWriteObjectPerfTest {
>     public static List<Integer> integerListOf(int length) {
>         List<Integer> integerList = new ArrayList<Integer>();
>         for (int index = 0; index < length; index++) {
>             integerList.add(index);
>         }
>         return integerList;
>     }
>     public static void timeOfXMLEncoder(int length) {
>         ByteArrayOutputStream baos = new ByteArrayOutputStream();
>         XMLEncoder xmlEncoder = new XMLEncoder(baos);
>         System.out.print("writing " + length + " of integers\t");
>         Object obj = integerListOf(length);
>         long start = System.currentTimeMillis();
>         xmlEncoder.writeObject(obj);
>         System.out.print("encode time:" + (System.currentTimeMillis() - start));
>         start = System.currentTimeMillis();
>         xmlEncoder.close();
>         System.out.println("\tflush time:"
>                 + (System.currentTimeMillis() - start));
>     }
>     public static void main(String[] args) {
>         for (int index = 0; index < 10; index++) {
>             System.out.println("*****INDEX=" + index + "*****");
>             timeOfXMLEncoder(5000);
>             timeOfXMLEncoder(10000);
>             timeOfXMLEncoder(15000);
>             timeOfXMLEncoder(20000);
>             timeOfXMLEncoder(25000);
>         }
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.