Esempio n. 1
0
        public UIBenchmarkComparison Run()
        {
            MakeSureFoldersExist();
            ConsoleProvider.Current.WindowWidth  = 150;
            ConsoleProvider.Current.BufferWidth  = 150;
            ConsoleProvider.Current.WindowHeight = 50;

            // throwaway
            var app = new ConsoleApp();

            RunActual(app);

            var output = new UIBenchmarkData[2];

            for (var i = 0; i < output.Length; i++)
            {
                using (var realRunApp = new ConsoleApp())
                {
                    var result = RunActual(realRunApp);
                    output[i] = new UIBenchmarkData()
                    {
                        WorkDone = result,
                    };
                }
            }

            var avg = UIBenchmarkData.Average(output);


            return(Compare(avg));
        }
Esempio n. 2
0
 public UIBenchmarkComparison Compare(UIBenchmarkData thisTestResults)
 {
     WriteTemp(thisTestResults);
     if (TryLoadLKG(out UIBenchmarkData lkgResults))
     {
         var ret = new UIBenchmarkComparison()
         {
             Test = GetType().Name, LKG = lkgResults, Temp = thisTestResults
         };
         if (ret.IsWin)
         {
             PromoteToLKG();
         }
         else
         {
             File.Delete(CurrentTestOutputFilePath);
         }
         return(ret);
     }
     else
     {
         PromoteToLKG();
         return(new UIBenchmarkComparison()
         {
             Test = GetType().Name, Temp = thisTestResults
         });
     }
 }
Esempio n. 3
0
 private bool TryLoadLKG(out UIBenchmarkData ret)
 {
     if (File.Exists(CurrentTestOutputLKGFilePath))
     {
         var contents = File.ReadAllText(CurrentTestOutputLKGFilePath);
         ret = JsonConvert.DeserializeObject <UIBenchmarkData>(contents);
         return(true);
     }
     ret = null;
     return(false);
 }
Esempio n. 4
0
        private void WriteTemp(UIBenchmarkData data)
        {
            var json = JsonConvert.SerializeObject(data, Formatting.Indented);

            File.WriteAllText(CurrentTestOutputFilePath, json);
        }