Initial Results

I just built both EHCache (1.2-beta4) and JCS (1.2.7.0) from head, configured both similarly and ran 20 rounds of 50,000 puts and gets, that is 1,000,000 puts and gets in total. Using the default LRU Memory Cache, the same algorithm that EHCache uses by default, JCS proved to be nearly twice as fast as EHCache in multiple trials for both puts and gets. I have the log levels for both set at info. I would like to further verify my results, since they completely contradict the information on the EHCache site.

From what I can tell so far, JCS is significantly faster than EHCache when you are retrieving items that exist in the cache and when you are putting items into a cache that has not reached its size limit.

Additional testing shows that when the size limit it reached, JCS and EHCache perform similarly for puts and gets. Although JCS gets are significantly faster when the items are present, they are almost exactly the same when the items are not in the cache. My initial tests revealed a less than 1% difference, but subsequent runs showed JCS as 20% faster. More tests are needed before the results are conclusive.

Since, neither cache will be a relevant bottleneck in any application where a cache would be useful, the differences in performance may be beside the point. Nevertheless, it is important to note that the EHCache web site provides, what appears to be, false test data.

The peculiar result is that a few years back EHCache took the JCS source code, removed most of its features, and ended up with something that performs worse.

Test Data

Here is the data from the first test:

JCS put time for 50000 = 651; millis per = 0.01302 JCS get time for 50000 = 160; millis per = 0.0032 EHCache put time for 50000 = 481; millis per = 0.00962 EHCache get time for 50000 = 110; millis per = 0.0022

JCS put time for 50000 = 240; millis per = 0.0048 JCS get time for 50000 = 90; millis per = 0.0018 EHCache put time for 50000 = 491; millis per = 0.00982 EHCache get time for 50000 = 120; millis per = 0.0024

JCS put time for 50000 = 241; millis per = 0.00482 JCS get time for 50000 = 80; millis per = 0.0016 EHCache put time for 50000 = 551; millis per = 0.01102 EHCache get time for 50000 = 110; millis per = 0.0022

JCS put time for 50000 = 240; millis per = 0.0048 JCS get time for 50000 = 90; millis per = 0.0018 EHCache put time for 50000 = 481; millis per = 0.00962 EHCache get time for 50000 = 130; millis per = 0.0026

JCS put time for 50000 = 230; millis per = 0.0046 JCS get time for 50000 = 181; millis per = 0.00362 EHCache put time for 50000 = 520; millis per = 0.0104 EHCache get time for 50000 = 101; millis per = 0.00202

JCS put time for 50000 = 220; millis per = 0.0044 JCS get time for 50000 = 90; millis per = 0.0018 EHCache put time for 50000 = 641; millis per = 0.01282 EHCache get time for 50000 = 110; millis per = 0.0022

JCS put time for 50000 = 250; millis per = 0.0050 JCS get time for 50000 = 121; millis per = 0.00242 EHCache put time for 50000 = 590; millis per = 0.0118 EHCache get time for 50000 = 101; millis per = 0.00202

JCS put time for 50000 = 260; millis per = 0.0052 JCS get time for 50000 = 100; millis per = 0.0020 EHCache put time for 50000 = 581; millis per = 0.01162 EHCache get time for 50000 = 100; millis per = 0.0020

JCS put time for 50000 = 290; millis per = 0.0058 JCS get time for 50000 = 121; millis per = 0.00242 EHCache put time for 50000 = 570; millis per = 0.0114 EHCache get time for 50000 = 121; millis per = 0.00242

JCS put time for 50000 = 210; millis per = 0.0042 JCS get time for 50000 = 120; millis per = 0.0024 EHCache put time for 50000 = 561; millis per = 0.01122 EHCache get time for 50000 = 130; millis per = 0.0026

JCS put time for 50000 = 250; millis per = 0.0050 JCS get time for 50000 = 151; millis per = 0.00302 EHCache put time for 50000 = 560; millis per = 0.0112 EHCache get time for 50000 = 111; millis per = 0.00222

JCS put time for 50000 = 250; millis per = 0.0050 JCS get time for 50000 = 100; millis per = 0.0020 EHCache put time for 50000 = 711; millis per = 0.01422 EHCache get time for 50000 = 100; millis per = 0.0020

JCS put time for 50000 = 251; millis per = 0.00502 JCS get time for 50000 = 90; millis per = 0.0018 EHCache put time for 50000 = 511; millis per = 0.01022 EHCache get time for 50000 = 90; millis per = 0.0018

JCS put time for 50000 = 220; millis per = 0.0044 JCS get time for 50000 = 100; millis per = 0.0020 EHCache put time for 50000 = 491; millis per = 0.00982 EHCache get time for 50000 = 90; millis per = 0.0018

JCS put time for 50000 = 230; millis per = 0.0046 JCS get time for 50000 = 80; millis per = 0.0016 EHCache put time for 50000 = 201; millis per = 0.00402 EHCache get time for 50000 = 390; millis per = 0.0078

JCS put time for 50000 = 201; millis per = 0.00402 JCS get time for 50000 = 120; millis per = 0.0024 EHCache put time for 50000 = 180; millis per = 0.0036 EHCache get time for 50000 = 411; millis per = 0.00822

JCS put time for 50000 = 210; millis per = 0.0042 JCS get time for 50000 = 100; millis per = 0.0020 EHCache put time for 50000 = 210; millis per = 0.0042 EHCache get time for 50000 = 381; millis per = 0.00762

JCS put time for 50000 = 240; millis per = 0.0048 JCS get time for 50000 = 90; millis per = 0.0018 EHCache put time for 50000 = 211; millis per = 0.00422 EHCache get time for 50000 = 410; millis per = 0.0082

JCS put time for 50000 = 221; millis per = 0.00442 JCS get time for 50000 = 80; millis per = 0.0016 EHCache put time for 50000 = 210; millis per = 0.0042 EHCache get time for 50000 = 411; millis per = 0.00822

JCS put time for 50000 = 220; millis per = 0.0044 JCS get time for 50000 = 80; millis per = 0.0016 EHCache put time for 50000 = 190; millis per = 0.0038 EHCache get time for 50000 = 411; millis per = 0.00822

Finished 20 loops of 50000 gets and puts

Put average for JCS = 256 Put average for EHCache = 447 JCS puts took 0.57270694 times the EHCache , the goal is less than 1.0x

Get average for JCS = 107 Get average for EHCache = 196 JCS gets took 0.54591835 times the EHCache , the goal is less than 1.0x

A Test Class

Here is the test class: