Beispiel #1
0
 /// <summary>
 /// start a test (in a number of separate threads)
 /// </summary>
 private void StartTest()
 {
     // create the pool object and start the test
     pool = new TraderPool(LogSafe, OnConnected);
     pool.Start(OnPoolStop);
     lblConnectionStatus.Text    = "connecting...";
     lblConnectionStatus.Visible = true;
     btnStop.Enabled             = true;
 }
Beispiel #2
0
        /// <summary>
        /// ensure the target folder and save the report's time
        /// </summary>
        public static void BuildReport(TraderPool pool)
        {
            var folder = $"{DateTime.Now:yyyy-MM-dd HHmmss}";

            EnsureFolder(folder);
            folder = ExecutablePath.Combine(RootFolder, folder);

            SaveStatisticsReport(pool, folder);
            SaveServerReport(pool, folder);
        }
Beispiel #3
0
 /// <summary>
 /// handle the test's finish
 /// </summary>
 private void OnPoolStop()
 {
     LogSafe("Stopping...");
     Invoke(new Action(() =>
     {
         TestReportBuilder.BuildReport(pool);
         pool                        = null;
         btnStop.Enabled             = false;
         lblConnectionStatus.Visible = false;
     }));
     LogSafe("Stopped");
 }
Beispiel #4
0
        /// <summary>
        /// save the report (included in the pool parameter) in a file
        /// </summary>
        private static void SaveStatisticsReport(TraderPool pool, string folder)
        {
            var stat     = pool.statistics;
            var jsonPath = Path.Combine(folder, "rawdata.js");
            var json     = stat.Stringify(false);

            using (var sw = new StreamWriter(jsonPath, false, Encoding.UTF8))
                sw.Write("window.rawdata = " + json);

            // copy report file
            var newPath = ExecutablePath.Combine(folder, "report.html");
            var srcPath = ExecutablePath.Combine("report.html");

            if (File.Exists(newPath))
            {
                File.Delete(newPath);
            }
            File.Copy(srcPath, newPath);
        }
Beispiel #5
0
 /// <summary>
 /// move the report file from the tempory path to the destination path ("report" folder)
 /// </summary>
 private static void SaveServerReport(TraderPool pool, string folder)
 {
     pool.serverStatPicker.CopyReportToTargetDir(folder);
 }