使用Gson官方的基准测试代码运行了一下如下:
0% Scenario{vm=java, trial=0, benchmark=Parse, api=JACKSON_STREAM, document=TWEETS} 315174.17 ns; σ=1279.77 ns @ 3 trials
8% Scenario{vm=java, trial=0, benchmark=Parse, api=GSON_STREAM, document=TWEETS} 317937.50 ns; σ=2252.69 ns @ 3 trials
17% Scenario{vm=java, trial=0, benchmark=Parse, api=GSON_SKIP, document=TWEETS} 215238.32 ns; σ=918.94 ns @ 3 trials
25% Scenario{vm=java, trial=0, benchmark=Parse, api=GSON_DOM, document=TWEETS} 449713.34 ns; σ=4438.43 ns @ 9 trials
33% Scenario{vm=java, trial=0, benchmark=Parse, api=JACKSON_STREAM, document=READER_SHORT} 56939.87 ns; σ=152.55 ns @ 3 trials
42% Scenario{vm=java, trial=0, benchmark=Parse, api=GSON_STREAM, document=READER_SHORT} 68554.89 ns; σ=528.70 ns @ 3 trials
50% Scenario{vm=java, trial=0, benchmark=Parse, api=GSON_SKIP, document=READER_SHORT} 45980.17 ns; σ=68.82 ns @ 3 trials
58% Scenario{vm=java, trial=0, benchmark=Parse, api=GSON_DOM, document=READER_SHORT} 83291.21 ns; σ=169.06 ns @ 3 trials
67% Scenario{vm=java, trial=0, benchmark=Parse, api=JACKSON_STREAM, document=READER_LONG} 1016519.88 ns; σ=5282.36 ns @ 3 trials
75% Scenario{vm=java, trial=0, benchmark=Parse, api=GSON_STREAM, document=READER_LONG} 790813.47 ns; σ=2151.96 ns @ 3 trials
83% Scenario{vm=java, trial=0, benchmark=Parse, api=GSON_SKIP, document=READER_LONG} 445050.62 ns; σ=12543.21 ns @ 10 trials
92% Scenario{vm=java, trial=0, benchmark=Parse, api=GSON_DOM, document=READER_LONG} 839990.27 ns; σ=10320.35 ns @ 10 trials
document api us linear runtime
TWEETS JACKSON_STREAM 315.2 =========
TWEETS GSON_STREAM 317.9 =========
TWEETS GSON_SKIP 215.2 ======
TWEETS GSON_DOM 449.7 =============
READER_SHORT JACKSON_STREAM 56.9 =
READER_SHORT GSON_STREAM 68.6 ==
READER_SHORT GSON_SKIP 46.0 =
READER_SHORT GSON_DOM 83.3 ==
READER_LONG JACKSON_STREAM 1016.5 ==============================
READER_LONG GSON_STREAM 790.8 =======================
READER_LONG GSON_SKIP 445.1 =============
READER_LONG GSON_DOM 840.0 ========================