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"); }
static public object ParseBySingleThread(string s) { ComplexTree <object> mt = JSONParser.CalculateComplexity(s); JSONParseThread.s = s; JSONNode n = JSONParseThread.Parse(mt[0]); return(n); }
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); }
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); }
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 SetUp() { //longlongstring = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "hugefile2.json"); //longlongstring = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "ReallyBigJSON.json"); longlongstring = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "FakeJSON.json"); ThreadPool.SetMaxThreads(65536, 65535); //ThreadPool.SetMinThreads(2000, 2000); if (!JSONParseThread.Initialized) { JSONParseThread.Initialize(); } }
static void Main(string[] args) { JSONParseThread.Initialize(); j = new JsonParser(); /* * FileStream ostrm; * StreamWriter writer; * TextWriter oldOut = Console.Out; * try * { * ostrm = new FileStream("./Redirect20.txt", FileMode.OpenOrCreate, FileAccess.Write); * writer = new StreamWriter(ostrm); * } * catch (Exception e) * { * Console.WriteLine("Cannot open Redirect.txt for writing"); * Console.WriteLine(e.Message); * return; * } * Console.SetOut(writer); */ ParseTest10MB(); GC.Collect(); Console.WriteLine("finished 10MB"); ParseTest1MB(); GC.Collect(); Console.WriteLine("finished 1MB"); ParseTest10KB1000(); GC.Collect(); Console.WriteLine("finished 10kb 1000times"); ParseTest100Byte100000(); Console.WriteLine("finished 100byte 100,000times"); GC.Collect(); //Console.SetOut(oldOut); //writer.Close(); //ostrm.Close(); //string end = Console.ReadLine(); }
public void ParseTest3() { string jsonstring = "[1,\"t\",true]"; ComplexTree <object> t = JSONParser.CalculateComplexity(jsonstring); JSONNode n = JSONParseThread.Parse(t[0]); }
public void ParseTest2() { string jsonstring = "{\"test\":12345}"; ComplexTree <object> t = JSONParser.CalculateComplexity(jsonstring); JSONNode n = JSONParseThread.Parse(t[0]); }