static void Main(string[] args) { s = new StopWatch(); int numOfTimes = 10000; SParse parse = new SParse(); parse.CreateTraditionalMatrix(); Console.WriteLine("Press enter key to start benchmark"); Console.ReadLine(); s.Start(); for (int i = 0; i < numOfTimes; i++) { parse.CreateSParseMy(); } s.Stop(); Console.WriteLine("My Time is:" + s.Elasped().ToString()); s = new StopWatch(); s.Start(); for (int i = 0; i < numOfTimes; i++) { parse.CreateSParseSir(); } s.Stop(); Console.WriteLine("Sir Time is:" + s.Elasped().ToString()); Console.ReadLine(); }
private void SirBtn_Click(object sender, System.EventArgs e) { if (ResultTxt.Text == "Ready for benchmark") { ResultTxt.Text = ""; } Task t = new Task(doSomething); t.Start(); void doSomething() { s.Start(); for (int i = 0; i < int.Parse(numOfTime.Text); i++) { parse.CreateSParseSir(); } s.Stop(); RunOnUiThread(new Action(() => ResultTxt.Text += "Sir time :" + s.Elasped().ToString() + "\n")); RunOnUiThread(new Action(() => s.Reset())); } }