I've performed some performance tests for the JDBC and JPA Appenders. The results are interesting and somewhat confusing, so I wanted to share them. All of these tests were run on Java 1.6.0_51 on a MacBook Pro 15" 2.5 GHz Intel Core i7 8GB 1333 MHz DDR3 running Mac OS X 10.7.5.
The abstract test classes for the JDBC and JPA Appenders each have a performance test method. It starts up the LoggerContext, logs a single event (to make sure everything is generally initialized), then starts a timer. It then logs 10,000 events (every 25th event includes an exception whose stack trace is logged) and then stops the timer. Finally, it selects all of the log events from the database table and ensures that 10,001 events appear. For each combination of JDBC+HyperSQL, JDBC+H2, JPA+HyperSQL, and JPA+H2, I ran the test 10 times and took the average of the 10. The spread was very minor and there were zero outliers. First, I tested the JDBCAppender: H2 consumed 738 milliseconds for 10,000 events (74 microseconds per event). I was rather impressed with this. HyperSQL consumed 3,507 milliseconds for 10,000 events (351 microseconds per event). I chalked this up to HyperSQL not performing as well as H2. Next, I tested the JPAAppender: H2 consumed 3,391 milliseconds for 10,000 events (339 microseconds per event). I expected JPA not to perform as well, but I was shocked at how much worse it was. HyperSQL consumed 4,105 milliseconds for 10,000 events (410 microseconds per event). Wait, what? So the performance difference between JDBC and JPA for H2 is huge, but the performance difference between JDBC and JPA for HyperSQL is minimal. This doesn't make a whole lot of sense to me. Thinking maybe JPA just needs a long time to warm up, I decided to double the events to 20,000: JDBC+H2 increased 49% to 1096 milliseconds (per event decreased 35% to 55 microseconds). JDBC+HyperSQL increased 70% to 5960 milliseconds (per event decreased 18% to 295 microseconds). JPA+H2 increased 52% to 5153 milliseconds (per event decreased 32% to 258 microseconds). JPA+HyperSQL increased 49% to 6119 milliseconds (per event decreased 35% to 306 microseconds). I'm not super sure what this means. I suppose it could be the fact that there are more columns it the database table for JPA events than the database table for JDBC events. I wouldn't think that would make that much difference, but it's possible. Either way, I'm not disappointed in the performance. It certainly isn't terrible, and it will be acceptable for most users I imagine. But I wonder if any of you might have any insights about what the deal could be here, or possibly you might look at the code and see that I've missed something. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
