public ConsoleApp(FileInfo fileOrFolder) { dialogic = new ChatRuntime(); dialogic.ParseFile(fileOrFolder); dialogic.Preload(globals); dialogic.Run(); }
public void SaveRestoreChats() { ChatRuntime rtOut, rtIn; var testfile = AppDomain.CurrentDomain.BaseDirectory; testfile += "../../../../dialogic/data/noglobal.gs"; rtIn = new ChatRuntime(Client.AppConfig.TAC); rtIn.ParseFile(new FileInfo(testfile)); var bytes = serializer.ToBytes(rtIn); rtOut = ChatRuntime.Create(serializer, bytes, AppConfig.TAC); // check they are identical Assert.That(rtIn, Is.EqualTo(rtOut)); var inCmds = rtIn.Chats(); var outCmds = rtOut.Chats(); Assert.That(rtOut.ToString(), Is.EqualTo(rtIn.ToString())); Assert.That(inCmds.Count, Is.EqualTo(outCmds.Count)); for (int i = 0; i < inCmds.Count; i++) { var chat1 = inCmds.ElementAt(i); var chat2 = outCmds.ElementAt(i); Assert.That(chat1.text, Is.EqualTo(chat2.text)); Assert.That(chat1.commands.Count, Is.EqualTo(chat2.commands.Count)); Assert.That(chat1.ToTree(), Is.EqualTo(chat2.ToTree())); } }
public void SerializationPerformance() { if (!RUN_PROFILING_TESTS) { return; } ChatRuntime.DISABLE_UNIQUE_CHAT_LABELS = true; ChatRuntime rtOut, rtIn; byte[] bytes = null; int iterations = 10; var testfile = AppDomain.CurrentDomain.BaseDirectory; testfile += "../../../../dialogic/data/allchats.gs"; rtIn = new ChatRuntime(Client.AppConfig.TAC); var watch = System.Diagnostics.Stopwatch.StartNew(); for (int i = 0; i < iterations; i++) { rtIn.ParseFile(new FileInfo(testfile)); } var numChats = rtIn.Chats().Count; watch.Stop(); Console.WriteLine("Parsed " + numChats + " chats in " + watch.ElapsedMilliseconds / 1000.0 + "s"); for (int i = 0; i < iterations; i++) { watch = System.Diagnostics.Stopwatch.StartNew(); bytes = serializer.ToBytes(rtIn); watch.Stop(); Console.WriteLine("Serialize #" + i + ": " + watch.ElapsedMilliseconds / 1000.0 + "s"); } for (int i = 0; i < iterations; i++) { watch = System.Diagnostics.Stopwatch.StartNew(); rtOut = ChatRuntime.Create(serializer, bytes, AppConfig.TAC); watch.Stop(); Console.WriteLine("Deserialize #" + i + ": " + watch.ElapsedMilliseconds / 1000.0 + "s"); } }