Beispiel #1
0
        public void TestReallyBigString()
        {
            Stopwatch s = Stopwatch.StartNew();

            ComplexTree <object> mt = JSONParser.CalculateComplexity(longlongstring);

            JSONParseThread.s = longlongstring;
            JSONParseThread.ParseThread(mt[0]);
            JSONNode n = mt[0].node;

            //Task t = Task.Factory.StartNew(() => { JSONNode n = JSONParseThread.ParseThread(mt[0], longlongstring); });
            //t.Wait();
            s.Stop();
            Console.WriteLine(s.Elapsed);
            Console.WriteLine(mt[0][0].Count);

            /*
             * Task t = Task.Factory.StartNew(()=>JSONParser.ParseStart((JSONNode n) =>
             * {
             *  s.Stop();
             *  Console.WriteLine(s.ElapsedTicks);
             *  File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "testout.txt", s.ElapsedTicks + "");
             *  return null;
             * }, longlongstring));
             * t.Wait();
             */
            Console.WriteLine("test function finished");
        }
Beispiel #2
0
        static public object ParseBySingleThread(string s)
        {
            ComplexTree <object> mt = JSONParser.CalculateComplexity(s);

            JSONParseThread.s = s;
            JSONNode n = JSONParseThread.Parse(mt[0]);

            return(n);
        }
Beispiel #3
0
        public void ComplexityTimeConsumeTest()
        {
            Stopwatch s = new Stopwatch();

            s.Start();
            JSONParseThread.Initialize();
            ComplexTree <object> t = JSONParser.CalculateComplexity(longlongstring);

            s.Stop();
            Console.WriteLine(s.Elapsed);
            Console.WriteLine(t[0].Count);
        }
Beispiel #4
0
        static public object ParseByMultiThread(string s)
        {
            ComplexTree <object> mt = JSONParser.CalculateComplexity(s);

            JSONParseThread.s = s;
            //JSONNode n = JSONParseThread.Parse(mt[0]);
            JSONParseThread.ParseThread(mt[0]);
            //Console.WriteLine(mt[0].StartPoint + " " + mt[0].EndPoint + " " + mt[0].Count);
            JSONNode n = mt[0].node;

            return(n);
        }
Beispiel #5
0
        public void TestBigStringSingleThread()
        {
            Stopwatch s = Stopwatch.StartNew();

            JSONParseThread.Initialize();
            ComplexTree <object> mt = JSONParser.CalculateComplexity(longlongstring);

            JSONParseThread.s = longlongstring;
            JSONNode n = JSONParseThread.Parse(mt[0]);

            s.Stop();
            Console.WriteLine(s.Elapsed);
            Console.WriteLine(n[0][0].value);
        }
        public void Remove_TheRootFromAThreeLevelTree_TheCorrectTree()
        {
            var firstNode = Node(9);
            var rootNode  = ComplexTree.RootElement;
            var bst       = ComplexTree.Create();

            bst.Remove(firstNode.Key);
            bst.Remove(rootNode.Key);

            NodeAssert.NotNullAndEqual(bst.Root, Node(10));
            NodeAssert.BothChildrenAreNotNull(bst.Root);

            NodeAssert.NotNullAndEqual(bst.Root.Right, Node(12));
            NodeAssert.BothChildrenAreNotNull(bst.Root.Right);
            NodeAssert.BothChildrenAreNull(bst.Root.Right.Left);
            NodeAssert.BothChildrenAreNotNull(bst.Root.Right.Right);

            NodeAssert.NotNullAndEqual(bst.Root.Left, Node(4));
            NodeAssert.BothChildrenAreNotNull(bst.Root.Left);
            NodeAssert.BothChildrenAreNotNull(bst.Root.Left.Left);
            NodeAssert.BothChildrenAreNotNull(bst.Root.Left.Right);
        }
Beispiel #7
0
 public void ParseTest3()
 {
     string jsonstring      = "[1,\"t\",true]";
     ComplexTree <object> t = JSONParser.CalculateComplexity(jsonstring);
     JSONNode             n = JSONParseThread.Parse(t[0]);
 }
Beispiel #8
0
 public void ParseTest2()
 {
     string jsonstring      = "{\"test\":12345}";
     ComplexTree <object> t = JSONParser.CalculateComplexity(jsonstring);
     JSONNode             n = JSONParseThread.Parse(t[0]);
 }
Beispiel #9
0
 public void ComplexityBasic()
 {
     ComplexTree <object> t = JSONParser.CalculateComplexity("{\"test\":{\"as{df\":123}, \"qq\":{}}");
 }