Skip to content

Commit

Permalink
- updated json benchmark tests
Browse files Browse the repository at this point in the history
  • Loading branch information
theburningmonk committed Aug 10, 2014
1 parent a927788 commit 5bddc13
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\SimpleSpeedTester\SimpleSpeedTester.csproj">
Expand Down
21 changes: 12 additions & 9 deletions examples/JsonSerializersBenchmark/JsonSerializersBenchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,34 @@
<Reference Include="Jayrock.Json">
<HintPath>..\..\packages\jayrock-json.0.9.16530\lib\net40\Jayrock.Json.dll</HintPath>
</Reference>
<Reference Include="Jil, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="Jil, Version=1.7.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Jil.1.5.0\lib\net45\Jil.dll</HintPath>
<HintPath>..\..\packages\Jil.1.7.0\lib\net45\Jil.dll</HintPath>
</Reference>
<Reference Include="JsonFx">
<HintPath>..\..\packages\JsonFx.2.0.1209.2802\lib\net40\JsonFx.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Bson, Version=1.9.1.221, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<Reference Include="MongoDB.Bson, Version=1.9.2.235, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\mongocsharpdriver.1.9.1\lib\net35\MongoDB.Bson.dll</HintPath>
<HintPath>..\..\packages\mongocsharpdriver.1.9.2\lib\net35\MongoDB.Bson.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver, Version=1.9.1.221, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<Reference Include="MongoDB.Driver, Version=1.9.2.235, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\mongocsharpdriver.1.9.1\lib\net35\MongoDB.Driver.dll</HintPath>
<HintPath>..\..\packages\mongocsharpdriver.1.9.2\lib\net35\MongoDB.Driver.dll</HintPath>
</Reference>
<Reference Include="NetJSON">
<HintPath>..\..\packages\NetJSON.1.0.0\lib\net40\NetJSON.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>..\..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="protobuf-net">
<HintPath>..\..\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Text, Version=4.0.22.0, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="ServiceStack.Text, Version=4.0.24.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\ServiceStack.Text.4.0.22\lib\net40\ServiceStack.Text.dll</HintPath>
<HintPath>..\..\packages\ServiceStack.Text.4.0.24\lib\net40\ServiceStack.Text.dll</HintPath>
</Reference>
<Reference Include="Sigil, Version=4.2.1.0, Culture=neutral, PublicKeyToken=2d06c3494341c8ab, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
24 changes: 24 additions & 0 deletions examples/JsonSerializersBenchmark/JsonSerializersSpeedTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

namespace SimpleSpeedTester.Example
{
using NetJSON;

/// <summary>
/// Demo program which compares the serializatoin and deserialization speed of 4 popular JSON serializers
/// </summary>
Expand Down Expand Up @@ -158,6 +160,14 @@ public static Dictionary<string, Tuple<ITestResultSummary, ITestResultSummary, d
DeserializeWithJil,
CountAverageJsonStringPayload));

results.Add(
"NetJson",
DoSpeedTest(
"NetJson",
SerializeWithNetJson,
DeserializeWithNetJson,
CountAverageJsonStringPayload));

results.Add(
"System.Text.Json",
DoSpeedTest(
Expand Down Expand Up @@ -557,6 +567,20 @@ private static List<SimpleObject> DeserializeWithJil(List<string> arg)
}

#endregion

#region NetJson

private static List<string> SerializeWithNetJson(List<SimpleObject> objects)
{
return objects.Select(NetJSON.Serialize).ToList();
}

private static List<SimpleObject> DeserializeWithNetJson(List<string> arg)
{
return arg.Select(NetJSON.Deserialize<SimpleObject>).ToList();
}

#endregion
}

[DataContract]
Expand Down
9 changes: 5 additions & 4 deletions examples/JsonSerializersBenchmark/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
<packages>
<package id="fastJSON" version="2.1.1.0" targetFramework="net45" />
<package id="jayrock-json" version="0.9.16530" targetFramework="net45" />
<package id="Jil" version="1.5.0" targetFramework="net45" />
<package id="Jil" version="1.7.0" targetFramework="net45" />
<package id="JsonFx" version="2.0.1209.2802" targetFramework="net45" />
<package id="mongocsharpdriver" version="1.9.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.3" targetFramework="net45" />
<package id="mongocsharpdriver" version="1.9.2" targetFramework="net45" />
<package id="NetJSON" version="1.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
<package id="protobuf-net" version="2.0.0.668" targetFramework="net45" />
<package id="ServiceStack.Text" version="4.0.22" targetFramework="net45" />
<package id="ServiceStack.Text" version="4.0.24" targetFramework="net45" />
<package id="Sigil" version="4.2.1" targetFramework="net45" />
<package id="System.Json" version="4.0.20126.16343" targetFramework="net45" />
<package id="System.Text.Json" version="1.9.9.1" targetFramework="net40" />
Expand Down

0 comments on commit 5bddc13

Please sign in to comment.