Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Quick JSON serializer performance test (Json.NET vs ServiceStack)

$
0
0

No pun intended but this is just a quick test between two popular JSON (de)serializers available for Xamarin iOS and Android. I will run iOS comparison later on but from previous experiments Android shows more difference between the two libraries.

Source code is available at GitHub in case you want to extend the tests or run them yourself: https://github.com/sami1971/SimplyMobile

Tests were compiled and ran in Release mode.

[NUnitLite] NUnit automated tests loaded.
[Runner executing:  Run Everything]
[M4A Version:   ???]
[Board:     tuna]
[Bootloader:    PRIMELA03]
[Brand:     samsung]
[CpuAbi:    armeabi-v7a armeabi]
[Device:    maguro]
[Display:   JOP40D.I9250XWMA2]
[Fingerprint:   samsung/yakjuxw/maguro:4.2.1/JOP40D/I9250XWMA2:user/release-keys]
[Hardware:  tuna]
[Host:      DELL123]
[Id:        JOP40D]
[Manufacturer:  samsung]
[Model:     Galaxy Nexus]
[Product:   yakjuxw]
[Radio:     unknown]
[Tags:      release-keys]
[Time:      1359045633000]
[Type:      user]
[User:      dpi.sec]
[VERSION.Codename:  REL]
[VERSION.Incremental:   I9250XWMA2]
[VERSION.Release:   4.2.1]
[VERSION.Sdk:       17]
[VERSION.SdkInt:    17]
[Device Date/Time:  11/6/2013 11:07:32 PM]
TextSerializationTests
JsonNetTests
    [FAIL] TestBase.CanSerializeInterface : Newtonsoft.Json.JsonSerializationException : Could not create an instance of type TextSerializationTests.IAnimal. Type is an interface or abstract class and cannot be instantated. Path 'Pets[0].Name', line 1, position 62.
          at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewObject (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract objectContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, Newtonsoft.Json.Serialization.JsonProperty containerProperty, System.String id, System.Boolean& createdFromNonDefaultConstructor) [0x00000] in <filename unknown>:0 
          at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0 
          at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <filename unknown>:0 
          at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList (IWrappedCollection wrappedList, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonArrayContract contract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, System.String id) [0x00000] in <filename unknown>:0 
SimplyMobile.Text.JsonNet.JsonSerializer took 1583ms deserializing 10000 iterations.
    Passed TestBase.DeserializationSpeed
SimplyMobile.Text.JsonNet.JsonSerializer took 425ms serializing 10000 iterations.
    Passed TestBase.SerializationSpeed
JsonNetTests : 2583.71 ms
ServiceStackTests
    Passed TestBase.CanSerializeInterface
SimplyMobile.Text.ServiceStack.JsonSerializer took 364ms deserializing 10000 iterations.
    Passed TestBase.DeserializationSpeed
SimplyMobile.Text.ServiceStack.JsonSerializer took 187ms serializing 10000 iterations.
    Passed TestBase.SerializationSpeed
ServiceStackTests : 1332.855 ms
TextSerializationTests : 3936.737 ms
Tests run: 6, Passed: 5, Failed: 1, Skipped: 0, Inconclusive: 0

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>