Benchmark not Benching
-
I'm attempting to code a mini processor benchmarking program(For fun :D) The problem is... Marks are always 0 :wtf:
marks
is a global int variablestring myWord = "1234567890"; StreamWriter sw = new StreamWriter(@"C:\benchMe.txt"); for (int j = 0; j < 1000; j++) { sw.Write(myWord); } sw.Flush(); sw.Close(); timer1.Interval = 1; MessageBox.Show("Test Ready!"); StreamReader sr = new StreamReader(@"C:\benchMe.txt"); string bob = sr.ReadToEnd(); sr.Close(); timer1.Enabled = true; // Begin Benchmark Console.WriteLine(bob); // There's a LARGE delay here. timer1.Enabled = false; MessageBox.Show("Marks on Test: " + marks); marks = 0; private void timer1_Tick(object sender, EventArgs e) { marks++; }
Any ideas? I was thinking that maybe the "Lag" was canceling the increment on the timer, or something... Any ideas, anyone? :) -
I'm attempting to code a mini processor benchmarking program(For fun :D) The problem is... Marks are always 0 :wtf:
marks
is a global int variablestring myWord = "1234567890"; StreamWriter sw = new StreamWriter(@"C:\benchMe.txt"); for (int j = 0; j < 1000; j++) { sw.Write(myWord); } sw.Flush(); sw.Close(); timer1.Interval = 1; MessageBox.Show("Test Ready!"); StreamReader sr = new StreamReader(@"C:\benchMe.txt"); string bob = sr.ReadToEnd(); sr.Close(); timer1.Enabled = true; // Begin Benchmark Console.WriteLine(bob); // There's a LARGE delay here. timer1.Enabled = false; MessageBox.Show("Marks on Test: " + marks); marks = 0; private void timer1_Tick(object sender, EventArgs e) { marks++; }
Any ideas? I was thinking that maybe the "Lag" was canceling the increment on the timer, or something... Any ideas, anyone? :)have you started the timer? timer1.Start(), timer1.Stop()
-
have you started the timer? timer1.Start(), timer1.Stop()
:omg: :sigh: :bashhead: -_- Ok, now it works (Once...) Benchmark code modified to:
private void button2_Click(object sender, EventArgs e) { StreamReader sr = new StreamReader(@"C:\benchMe.txt"); string bob = sr.ReadToEnd(); sr.Close(); timer1.Start(); Console.WriteLine(bob); timer1.Stop(); MessageBox.Show("Marks on Test: " + marks); marks = 0; }
First click displays marks, second click -> x click displays 0. So close.... :) -
:omg: :sigh: :bashhead: -_- Ok, now it works (Once...) Benchmark code modified to:
private void button2_Click(object sender, EventArgs e) { StreamReader sr = new StreamReader(@"C:\benchMe.txt"); string bob = sr.ReadToEnd(); sr.Close(); timer1.Start(); Console.WriteLine(bob); timer1.Stop(); MessageBox.Show("Marks on Test: " + marks); marks = 0; }
First click displays marks, second click -> x click displays 0. So close.... :)glad it helped
-
I'm attempting to code a mini processor benchmarking program(For fun :D) The problem is... Marks are always 0 :wtf:
marks
is a global int variablestring myWord = "1234567890"; StreamWriter sw = new StreamWriter(@"C:\benchMe.txt"); for (int j = 0; j < 1000; j++) { sw.Write(myWord); } sw.Flush(); sw.Close(); timer1.Interval = 1; MessageBox.Show("Test Ready!"); StreamReader sr = new StreamReader(@"C:\benchMe.txt"); string bob = sr.ReadToEnd(); sr.Close(); timer1.Enabled = true; // Begin Benchmark Console.WriteLine(bob); // There's a LARGE delay here. timer1.Enabled = false; MessageBox.Show("Marks on Test: " + marks); marks = 0; private void timer1_Tick(object sender, EventArgs e) { marks++; }
Any ideas? I was thinking that maybe the "Lag" was canceling the increment on the timer, or something... Any ideas, anyone? :)You have mentioned the timer interval as 1ms. If the interval is less than 15ms (sometimes this will be more according to the processor/hardware.) it is not going to perform correctly. This article will explain it clearly. Timer surprises, and how to avoid them[^]
*jaans
-
You have mentioned the timer interval as 1ms. If the interval is less than 15ms (sometimes this will be more according to the processor/hardware.) it is not going to perform correctly. This article will explain it clearly. Timer surprises, and how to avoid them[^]
*jaans
-
I'm attempting to code a mini processor benchmarking program(For fun :D) The problem is... Marks are always 0 :wtf:
marks
is a global int variablestring myWord = "1234567890"; StreamWriter sw = new StreamWriter(@"C:\benchMe.txt"); for (int j = 0; j < 1000; j++) { sw.Write(myWord); } sw.Flush(); sw.Close(); timer1.Interval = 1; MessageBox.Show("Test Ready!"); StreamReader sr = new StreamReader(@"C:\benchMe.txt"); string bob = sr.ReadToEnd(); sr.Close(); timer1.Enabled = true; // Begin Benchmark Console.WriteLine(bob); // There's a LARGE delay here. timer1.Enabled = false; MessageBox.Show("Marks on Test: " + marks); marks = 0; private void timer1_Tick(object sender, EventArgs e) { marks++; }
Any ideas? I was thinking that maybe the "Lag" was canceling the increment on the timer, or something... Any ideas, anyone? :)I read this a couple of times, and I'm not 100% sure what all of it is doing, so forgive me if Im a little off the mark with this... Have you looked at System.Diagnostics.Stopwatch at all? If what you are going for is performance testing you could have something like: const int NumberOfTests = 1000000; System.Diagnostics.Stopwatch s = new System.Diagnostics.Stopwatch(); s.Start(); for (int i = 0; i < NumberOfTests; i++) { //Code to test goes here! } s.Stop(); MessageBox.Show(s.ElapsedMilliseconds.ToString()); (Rinse and repeat for multiple benchmarks) Hope that helps, Chris
-
I read this a couple of times, and I'm not 100% sure what all of it is doing, so forgive me if Im a little off the mark with this... Have you looked at System.Diagnostics.Stopwatch at all? If what you are going for is performance testing you could have something like: const int NumberOfTests = 1000000; System.Diagnostics.Stopwatch s = new System.Diagnostics.Stopwatch(); s.Start(); for (int i = 0; i < NumberOfTests; i++) { //Code to test goes here! } s.Stop(); MessageBox.Show(s.ElapsedMilliseconds.ToString()); (Rinse and repeat for multiple benchmarks) Hope that helps, Chris