XML : Why does the average execution time for JAXB conversion to XML decrease as the number of elements in the list increase?

I have a list containing some objects, which are converted to XML using JAXB. As I increase the number of records in the list, the time taken for conversion doesn't increase linearly. For 1 record, the time taken was .2 seconds; for 10000 records, the time taken was only 7 seconds. How did the average time for conversion decrease?

  long start = System.currentTimeMillis();  list.stream().forEach(Converter::toXml);  long end = System.currentTimeMillis();  System.out.println("Time taken for " + list.size() + " : " + (end-start));    

P.S. I'm not including the time taken to populate the list.

No comments:

Post a Comment