Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-6664

[classlib][beans] Poor performance of java.beans.XMLEncoder.writeObject() method

    XMLWordPrintableJSON

    Details

    • Type: Task
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.0M15
    • Fix Version/s: 6.0M4
    • Component/s: Classlib
    • Labels:
      None
    • Estimated Complexity:
      Moderate

      Description

      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); }

      }
      }

        Attachments

        1. HARMONY-6664.diff
          5 kB
          Kevin Zhou
        2. HARMONY-6664.v2.diff
          30 kB
          Kevin Zhou

          Activity

            People

            • Assignee:
              zhoukevin Kevin Zhou
              Reporter:
              zhoukevin Kevin Zhou
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 48h
                48h
                Remaining:
                Remaining Estimate - 48h
                48h
                Logged:
                Time Spent - Not Specified
                Not Specified