private void cv01btnBenchmark_Click_1(object sender, EventArgs e) { int LASTTOMEASURE = 11; Dictionary<int, float> times = new Dictionary<int, float>(); cv01txtBenchmark.Text = ""; task01 = new Task01(GUI.GetWidth(), GUI.GetHeight(), GUI.GetPointSize()); //run one simple benchmark to avoid startup delays in statistics task01.GeneratePoints(3); task01.Benchmark(null); for (int i = 3; i <= LASTTOMEASURE; i++) { task01.GeneratePoints(i); cv01txtBenchmark.Text += String.Format("Starting benchmark for {0} points...\r\n", i); cv01txtBenchmark.ScrollToCaret(); cv01txtBenchmark.Refresh(); Stopwatch s = new Stopwatch(); StringBuilder sb = new StringBuilder(); s.Start(); bool debugmode = false; if (task01.Points.Count < 8 && debugmode) task01.Benchmark(sb); //debug mode else task01.Benchmark(null); //no debug mode s.Stop(); double ms = s.Elapsed.TotalMilliseconds; cv01txtBenchmark.Text += sb.ToString(); cv01txtBenchmark.Text += String.Format("Benchmark for {0} points finished in {1} ms.\r\n", i, ms); cv01txtBenchmark.ScrollToCaret(); cv01txtBenchmark.Refresh(); times[i] = (float)Math.Round(ms / 1000, 3); chart.Plot(times); chart.Refresh(); } //estimate the rest for (int i = LASTTOMEASURE + 1; i <= 15; i++) { times[i] = times[(i - 1)] * i; chart.Plot(times); cv01txtBenchmark.Text += String.Format("Approximated results for {0} points: {1} ms.\r\n", i, times[i] * 1000); chart.Refresh(); } chart.Plot(times); }
private void cv01btnCount_Click(object sender, EventArgs e) { canvas.Init(); task01 = new Task01(GUI.GetWidth(), GUI.GetHeight(), GUI.GetPointSize()); task01.GeneratePoints((int)cv01numPoints.Value); //cv01txtBenchmark.Text = ""; cv01txtTotal.Text = String.Format("{0}", task01.EdgeCount); //foreach (Tasks.Point p in task01.Points) // cv01txtBenchmark.Text += String.Format("X={0}, Y={1}\r\n", p.X, p.Y); //canvas.DrawPoints(task01.Points); //canvas.DrawPath(new Path(task01.Points), true, false); }