Click here to Skip to main content
15,879,326 members
Articles / Programming Languages / Markdown

APJSON

Rate me:
Please Sign up or sign in to vote.
4.67/5 (5 votes)
28 Aug 2013CPOL13 min read 41.6K   1.2K   34  
This is an alternative for "fastJSON"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using consoletest.DataObjects;

namespace consoletest
{
    public static partial class Benchmarks
    {
        private static void FastJson_Deserialize()
        {
            Console.WriteLine();
            Console.Write("fastJSON 2.0.9 decode    ");
            FastJsonBenchmarkClass c = CreateTestedObject();

            string jsonText = fastJSON.JSON.Instance.ToJSON(c);

            InitTestRun();

            for (int pp = 0; pp < tcount; pp++)
            {
                stopwatch.Reset();
                stopwatch.Start();

                FastJsonBenchmarkClass deserializedStore;

                for (int i = 0; i < count; i++)
                {
                    deserializedStore = (FastJsonBenchmarkClass)fastJSON.JSON.Instance.ToObject(jsonText);
                }

                stopwatch.Stop();
                Console.Write("\t" + stopwatch.ElapsedMilliseconds);
                testRunDurations.Add(stopwatch.ElapsedMilliseconds);
            }

            WriteAverage(true);
        }

        private static void FastJson_Serialize()
        {
            Console.WriteLine();
            Console.Write("fastJSON 2.0.9 encode    ");
            FastJsonBenchmarkClass 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 = fastJSON.JSON.Instance.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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions