Example #1
0
        public ResultPrinter(List<TestResult> testResults, Algorithm algorithm)
        {
            _testResults = testResults;
              _algorithm = algorithm;

              GeneratorSetup generatorSetup = null;
              if (_testResults.Count > 0)
            generatorSetup = _testResults[0].GeneratorSetup;

              if (File.Exists(GetFileName(null)))
              {
            File.Delete(GetFileName(null));
              }
        }
Example #2
0
        public List<TestResult> RunAllTests(Algorithm algorithm)
        {
            List<TestResult> testResults = new List<TestResult>();
              foreach (Test test in _tests)
              {
            //Console.WriteLine("MEM BEF {0} KiB", GC.GetTotalMemory(false) / 1024);
            GC.Collect();
            GC.WaitForPendingFinalizers();
            //Console.WriteLine("MEM AF {0} KiB", GC.GetTotalMemory(true) / 1024);

            //GC.TryStartNoGCRegion(1024 * 1024 * 240, true);
            testResults.Add(test.RunTest(algorithm));
            //GC.EndNoGCRegion();
            Console.WriteLine("[" + testResults[testResults.Count - 1].N + "] done.");
              }
              return testResults;
        }
Example #3
0
        private string GetFileName(Algorithm algorithm)
        {
            string config = "";
              if (algorithm == null)
              {
            config = _algorithm.GetConfig();
              }

              string dirWithSlash = "";

              if (algorithm != null)
            dirWithSlash = algorithm.GetType().Name + "/";

              if (!string.IsNullOrEmpty(dirWithSlash))
              {
            Directory.CreateDirectory(dirWithSlash.Substring(0, dirWithSlash.Length - 1));
              }

              string fileId;

              if (algorithm != null)
              {
            fileId = "gen";
              }
              else
              {
            if (string.IsNullOrEmpty(config))
            {
              fileId = _algorithm.GetType().Name;
            }
            else
            {
              config = config.Replace(".", "_").Replace(":", "-").Replace(" ", "-");
              fileId = _algorithm.GetType().Name + "_" + config;
            }
              }

              return dirWithSlash + "results_" + fileId + ".txt" ;
        }
Example #4
0
 public int Solve(Algorithm algorithm)
 {
     algorithm.Knapsack = this;
       return algorithm.Solve();
 }
Example #5
0
 private void Out(string text, Algorithm algorithm)
 {
     File.AppendAllText(GetFileName(algorithm), text);
       Console.Write(text);
 }