DISCLAIMER : as always, you should bench­mark against your pay­load and use case, the bench­mark num­bers I have pro­duced here is unlikely to be rep­re­sen­ta­tive of your use cases and nei­ther is any­body else’s bench­mark numbers.

You can use the sim­ple test har­ness I cre­ated and see these exam­ple code to bench­mark against your par­tic­u­lar payload.

 

Json.Net, ServiceStack.Text, Mon­goDB Drive and Jil were all updated to the lat­est version.

Rpg­Maker’s NetJ­son seri­al­izer has also been added to the mix and the results are really impres­sive with a level of per­for­mance that’s almost iden­ti­cal to protobuf-net!

image

image

 

Ver­sions tested:

Jil 1.7.0
ServiceStack.Text 4.0.24
Json.Net 6.0.4
fastJ­son 2.1.1.0
Mon­goDB Drive 1.9.2
System.Json 4.0.20126.16343
System.Text.Json 1.9.9.1
JsonFx 2.0.1209.2802
Jay­Rock 0.9.16530
Share
  • rpg­maker

    Thanks for the bench­mark. By includ­ing the min and max for the out­come, NetJ­SON beats Protobuf-net all the time. Can you post a result that does not elim­i­nate the min and max of the result so as to to see what dif­fer­ent it makes?

    Thanks again.

  • rpg­maker

    Here is my result. I excluded the other seri­al­iz­ers to elim­i­nate noises and left just netj­son and protobuf-net.

    - With Out­come Fil­ter of Min and Max

    Test Group [Protobuf-Net], Test [Seri­al­iza­tion] results summary:

    Suc­cesses [5]

    Fail­ures [0]

    Aver­age Exec Time [144.405366666667] milliseconds

    Test Group [Protobuf-Net] aver­age seri­al­ized byte array size is [51.7227]

    Test Group [Protobuf-Net], Test [Dese­ri­al­iza­tion] results summary:

    Suc­cesses [5]

    Fail­ures [0]

    Aver­age Exec Time [236.163266666667] milliseconds

    ———————————————————

    Test Group [NetJ­son], Test [Seri­al­iza­tion] results summary:

    Suc­cesses [5]

    Fail­ures [0]

    Aver­age Exec Time [151.2176] milliseconds

    Test Group [NetJ­son] aver­age seri­al­ized byte array size is [98.86646]

    Test Group [NetJ­son], Test [Dese­ri­al­iza­tion] results summary:

    Suc­cesses [5]

    Fail­ures [0]

    Aver­age Exec Time [252.5274] milliseconds

    ———————————————————

    - With­out Out­come Fil­ter of Min and Max

    Test Group [Protobuf-Net], Test [Seri­al­iza­tion] results summary:

    Suc­cesses [5]

    Fail­ures [0]

    Aver­age Exec Time [257.9771] milliseconds

    Test Group [Protobuf-Net] aver­age seri­al­ized byte array size is [51.72424]

    Test Group [Protobuf-Net], Test [Dese­ri­al­iza­tion] results summary:

    Suc­cesses [5]

    Fail­ures [0]

    Aver­age Exec Time [251.4977] milliseconds

    ———————————————————

    Test Group [NetJ­son], Test [Seri­al­iza­tion] results summary:

    Suc­cesses [5]

    Fail­ures [0]

    Aver­age Exec Time [157.98844] milliseconds

    Test Group [NetJ­son] aver­age seri­al­ized byte array size is [98.86456]

    Test Group [NetJ­son], Test [Dese­ri­al­iza­tion] results summary:

    Suc­cesses [5]

    Fail­ures [0]

    Aver­age Exec Time [252.18208] milliseconds

    ———————————————————

  • Pingback: F# Weekly #32, 2014 | Sergey Tihon's Blog

  • Yan Cui

    A lot of seri­al­iz­ers incur a ‘start-up’ cost (reflec­tion, etc. before these are cached) and that cost is amor­tized over time which is why they’re excluded from the results.

  • rpg­maker

    I guess that make sense. So it seem like protobuf-net would be one of the seri­al­iz­ers that incur a start up cost due to all the reflec­tion and caching it does.

  • ??????? ???????????

    Why not just con­tibute to Json.NET?
    Json.NET is used widely, even in ASP.NET MVC4, it’s unpos­si­ble to switch it to NetJ­son BUT it’s easy to update Json.NET binary assem­bly with updated version.

  • Cocoa

    NetJ­SON = fastest out there, besides pro­to­buf isn’t even JSON, and it still is barely faster, that is also exclud­ing the startup costs of Pro­to­buf.. poor protobuf;

  • Yan Cui

    I started to include pro­to­buf in there as a guide so that every­one could see that there’s a dif­fer­ence in terms of per­for­mance between binary and BSON seri­al­iz­ers so that they can make more informed deci­sion as to which to use (http://theburningmonk.com/2012/08/performance-test-json-serializers-part-iii/).

    The fact that NetJ­son blurs that line is amaz­ing news, and with­out putting them side-by-side how would one know that it does?

  • rpg­maker

    When you do get a chance, can you rerun the bench­mark again with the lat­est ver­sion of NetJ­SON 1.0.2? Based on your sim­pleTester it beats protobuf-net no mat­ter if you include or exclude the min/max time.

    Thanks,

  • Paul West­cott

    NetJ­son doesn’t appear to escape strings, so prob­a­bly shouldn’t be included as a json seri­aliser — i.e. it’s use is sev­erly limited.

  • rpg­maker

    The logic to escape strings is already in the code. It is just not been called because I want to test it well before enabling it. So far adding it does not make it slower than protobuf-net. It is still faster than all the json seri­al­izer on the list.

    I have an issue open for since the begin­ning: https://github.com/rpgmaker/NetJSON/issues/1

  • rpg­maker