Apache POI Performance

2019-03-10 07:08发布

问题:

I'm having performance problems with Apache POI. I've read the FAQ where it refers to a performance test. I've run this test with logging off and 4gb of heap and I can't get the tests to run faster than 22 seconds.

This is the test I'm running: http://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/ss/examples/SSPerformanceTest.java

The FAQ says that if I can't get this test to run in under 3 seconds with 50,000 rows and 50 columns that "the problem is with your environment". I've read other comments around the web referring to disabling poi logging and increasing the heap size, but nothing seems to help.

What else can I check to fix my environment?

Machine Specs (Personal desktop machine):

CPU: Intel i7 8-cores
RAM: 16GB
OS: Windows 7 64bit
JDK: 1.8.0_66
POI: 3.13
JVM Params: -Xmx4g -Xms4g -Dorg.apache.poi.util.POILogger=org.apache.poi.util.NullLogger
Command Arguments: XSSF 50000 50 0

I should also mention that the Apache POI jars I'm using came from maven central

I've created a test project on github where you can simply clone the project and run:

mvn exec:java

I hard coded the parameters I'm using so you do not have to enter anything special on the command line. The documentation says this should run in under 3 seconds.

The test project is located here: https://github.com/mikedehaan/poi-test

回答1:

Test results on my machine:

  • HSSF: 2 sec
  • SXSSF: 5 sec
  • XSSF: 27 sec

Machine specs:

CPU: Intel i3-2100, 3.10 GHz, 4-cores
RAM: 16GB
OS:  Windows 7 64bit
JDK: 1.7.0_76

I made profiling and found out that XSSF is slow due to the synchronized methods in xmlbeans and poi-ooxml-schemas libraries. You can notify poi developers and ask to check this case.