If using a logger in a software project for logging the program flow, it's important that the logger is very fast to prevent negative influence to the program flow itself. Therefore the performance of a logger is really important. Today multi-core processors become more and more important because the power per core seems to reach an upper limit. Every modern PC has at least two or four cores. So programs must use multiple threads to use these multiple cores. So it's important that a logger won't block all threads if these log parallel.
The benchmark created 120 times 100,000 log entries. The ten worst and the ten best results were ignored to remove outliers. From the 100 remaining runs the run times were added (= 10 million log entries). This was done once with all 100,000 log entries in one thread to test the single-threading performance and another time with 10,000 log entries in ten parallel threads to test the multi-threading performance.
To create comparable results for tinylog (version 0.6), the benchmark was repeated with the logger included in the JDK 6, the popular Log4j (version 1.2.16) and its (inofficial) successor Logback (version 1.0.0 with Simple Logging Facade 1.6.4).
All benchmarks were run on an Intel Core i7 CPU 870 (2.93 GHz quad-core) with Windows XP and JRE 6u17 / JDK 1.6.0_17.
Run time to create 10 million log entries:
1 min 33 s
2 min 00 s
2 min 15 s
2 min 36 s
2 min 44 s
3 min 16 s
3 min 49 s
|Legend: One thread Multiple threads|
tinylog was in both test cases the fastest logger in the benchmark. With one single thread tinylog is almost half a minute faster than the second one - the JDK logger. tinylog is the only logger that won't slow down if multiple threads log parallel. Quite the contrary: tinylog benefits from the cores and is more than twice faster than with one single thread.
The benchmark is available on the download page.