java icon indicating copy to clipboard operation
java copied to clipboard

STATIC_MODE seems to be SLOWER then DYNAMIC_MODE

Open mburger81 opened this issue 7 years ago • 4 comments

Hey, we tested your demo example in java and doing some benchmark tests, with your example it seems the STATIC_MODE which should be the fastest mode is much more slower then the DYNAMIC_MODE.

If we loop it thorugh 10000+ times we se a bug performance difference.

Also we noticed your documentation seems on some buggy.

mburger81 avatar Jul 19 '18 14:07 mburger81

can you provide a benchmark to reproduce?

taowen avatar Jul 20 '18 02:07 taowen

I created a new repo https://github.com/mburger81/jsoniter-test where I have invited you to be a collaborator.

I tested this scenario where I created a new Pojo class and serialize it 1000000 times

This is my benchmark result

without setMode: 1856 -> this should be same es reflection right?
Reflection: 1846ms
DynamicMode: 1285ms
StaticMode: 1224ms

As you can see in this case it seems the static mode is the fastest one, nearly the same as dynamic mode. I have the big problem we have to serialize json on a embeded system and nee much performance as possible. On another test on another project we did before, the static mode was slower it could be we did something wrong there. Having a look there seems to be a -30% comparing to reflection, is that what we can expect?

mburger81 avatar Jul 20 '18 14:07 mburger81

I confirm making similar observation. We ran some comparison tests and found that STATIC mode is somewhat slower than DYNAMIC. The warmup is definitely much slower for STATIC. Quite strange results.

patrushev avatar Mar 12 '19 19:03 patrushev

Try using JMH to benchmark.

On Wed, Mar 13, 2019 at 3:32 AM patrushev [email protected] wrote:

I confirm making similar observation. We ran some comparison tests and found that STATIC mode is somewhat slower than DYNAMIC. The warmup is definitely much slower for STATIC. Quite strange results.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/json-iterator/java/issues/197#issuecomment-472148952, or mute the thread https://github.com/notifications/unsubscribe-auth/AACeXbB61kfW5G5alpYhFoBBm0TsuAn9ks5vWADHgaJpZM4VWhgK .

taowen avatar Mar 18 '19 01:03 taowen