Memory and execution time comparison between my code and apache poi

I am in the middle of writing a XLSX parser. My usecase is just to read a spreadsheet and store the cell values into some object structure.

Once complete, I want to compare my code’s performance (memory and time) with that of Apache Poi.

For time comparison, I was thinking of checking the delta System.nanotime().
I will parse the xlsx multiple times in a loop to make sure the execution time is in the order of seconds and then average.

I need help with the following:

  1. Is there a better way to compare execution time?
  2. How can I compare the memory footprint of my code with Poi?

Could anybody help with some information/suggestion please?

Answer

Is there a better way to compare execution time?

When writing your own micro benchmark, you should take into account the tips explained here: How do I write a correct micro-benchmark in Java?.

After reading that info, you should understand that is not that easy to write micro benchmarks by yourself. That’s why there are micro benchmark libraries that eases this work like JUnitBenchmarks and Caliper.

How can I compare the memory footprint of my code with Poi?

I have used profilers to measure the memory used for the algorithms I have developed, but probably that’s not what you’re looking for. And the other approach you may use is by simply calculating runtime.totalMemory() - runtime.freeMemory(). You can find more info about how to get the memory footprint for your tests here:
Java unit testing: how to measure memory footprint for method call

Leave a Reply

Your email address will not be published. Required fields are marked *