|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Apolyton.FastJson.Data;
namespace consoletest
{
public static partial class Benchmarks
{
private static void Apolyton_FastJson_Deserialize()
{
Console.WriteLine();
Console.Write("(A) FastJSON decode ");
ClassWithAllSupportedTypes c = CreateTestedObject();
string jsonText = fastJSON.JSON.Instance.ToJSON(c);
InitTestRun();
for (int pp = 0; pp < tcount; pp++)
{
stopwatch.Reset();
stopwatch.Start();
ClassWithAllSupportedTypes deserializedStore;
for (int i = 0; i < count; i++)
{
deserializedStore = (ClassWithAllSupportedTypes)Apolyton.FastJson.Json.Current.ReadObject(jsonText);
}
stopwatch.Stop();
Console.Write("\t" + stopwatch.ElapsedMilliseconds);
testRunDurations.Add(stopwatch.ElapsedMilliseconds);
}
WriteAverage(true);
}
private static void Apolyton_FastJson_Deserialize_JsonObject()
{
Console.WriteLine();
Console.Write("(A) FastJSON decode JVal ");
ClassWithAllSupportedTypes c = CreateTestedObject();
string jsonText = fastJSON.JSON.Instance.ToJSON(c);
InitTestRun();
for (int pp = 0; pp < tcount; pp++)
{
stopwatch.Reset();
stopwatch.Start();
JsonObject deserializedStore;
for (int i = 0; i < count; i++)
{
deserializedStore = (JsonObject)Apolyton.FastJson.Json.Current.ReadJsonValue(jsonText);
}
stopwatch.Stop();
Console.Write("\t" + stopwatch.ElapsedMilliseconds);
testRunDurations.Add(stopwatch.ElapsedMilliseconds);
}
WriteAverage(true);
}
private static void Apolyton_FastJson_Deserialize_JsonObject_BuildUp()
{
Console.WriteLine();
Console.Write("(A) FastJSON decode JVal+Bld");
ClassWithAllSupportedTypes c = CreateTestedObject();
ClassWithAllSupportedTypes target;
string jsonText = fastJSON.JSON.Instance.ToJSON(c);
InitTestRun();
for (int pp = 0; pp < tcount; pp++)
{
stopwatch.Reset();
stopwatch.Start();
JsonObject deserializedStore;
target = new ClassWithAllSupportedTypes();
for (int i = 0; i < count; i++)
{
deserializedStore = (JsonObject)Apolyton.FastJson.Json.Current.ReadJsonValue(jsonText);
Apolyton.FastJson.Json.Current.BuildUp(target, deserializedStore);
}
stopwatch.Stop();
Console.Write("\t" + stopwatch.ElapsedMilliseconds);
testRunDurations.Add(stopwatch.ElapsedMilliseconds);
}
WriteAverage(true);
}
private static void ApolytonFastJson_serialize()
{
Console.WriteLine();
Console.Write("(A) FastJSON encode ");
ClassWithAllSupportedTypes c = CreateTestedObject();
InitTestRun();
for (int pp = 0; pp < tcount; pp++)
{
stopwatch.Reset();
stopwatch.Start();
string jsonText = null;
for (int i = 0; i < count; i++)
{
jsonText = Apolyton.FastJson.Json.Current.ToJson(c);
}
stopwatch.Stop();
Console.Write("\t" + stopwatch.ElapsedMilliseconds);
testRunDurations.Add(stopwatch.ElapsedMilliseconds);
}
WriteAverage(true);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.