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