static void Main(string[] args) { var gate = new AutoResetEvent(false); Exception exception = null; var server = new CassiniDevServer(); var path = new ContentLocator("WcfRestService1").LocateContent(); server.StartServer(path); var client = new SampleClient(server.NormalizeUrl("").TrimEnd('/')); var recorder = new Recorder(client); recorder .Start(); client.BeginListService1(ar => { try { List<SampleItem> result = client.EndListService1(ar); Console.WriteLine(DateTime.Now + " " + result.Count); } catch (Exception ex) { exception = ex; } finally { gate.Set(); } }, null); Wait(exception, gate); server.StopServer(); server.Dispose(); var recording = recorder.GetRequests(); recorder.Dispose(); var serializedRecording = client.Serializer.SerializeObject(recording); client.Dispose(); File.WriteAllText("output.txt", serializedRecording); }
static void Main(string[] args) { try { var curProcess = Process.GetCurrentProcess(); var secondsOnStart = curProcess.TotalProcessorTime.TotalSeconds; var totalWatch = Stopwatch.StartNew(); for (int i = 0; i < 20; i++) { var client = new Client(Const.RPC_URI, Const.STREAMING_URI, ""); var recorder = new Recorder(client); recorder.Start(); var loginWatch = Stopwatch.StartNew(); client.LogIn(Const.USERNAME, Const.PASSWORD); loginWatch.Stop(); var accountInfoWatch = Stopwatch.StartNew(); var accountInfo = client.AccountInformation.GetClientAndTradingAccount(); accountInfoWatch.Stop(); var listSpreadMarketsWatch = Stopwatch.StartNew(); var resp = client.SpreadMarkets.ListSpreadMarkets("", "", accountInfo.ClientAccountId, 100, false); listSpreadMarketsWatch.Stop(); var logoutWatch = Stopwatch.StartNew(); client.LogOut(); logoutWatch.Stop(); var purgeHandle = client.ShutDown(); if (!purgeHandle.WaitOne(60000)) throw new ApplicationException(); var requests = recorder.GetRequests(); if (requests.Count != 4) throw new ApplicationException(); AddResult(loginWatch, requests[0], "Login"); AddResult(accountInfoWatch, requests[1], "GetClientAndTradingAccount"); AddResult(listSpreadMarketsWatch, requests[2], "ListSpreadMarkets"); AddResult(logoutWatch, requests[3], "Logout"); recorder.Stop(); recorder.Dispose(); client.Dispose(); } totalWatch.Stop(); var secondsOnEnd = curProcess.TotalProcessorTime.TotalSeconds; Console.WriteLine("CPU time used, seconds: {0} total time: {1}", secondsOnEnd - secondsOnStart, totalWatch.Elapsed.TotalSeconds); } catch (Exception exc) { Console.WriteLine(exc); } Debugger.Break(); }