Re: how long a program runs
im assuming you mean how long it takes a section of code to run correct?
imports:
Code:
imports system.diagnostics
put this before the code that is taking forever:
Code:
Dim sw as new stopwatch
sw.start()
at the end of the code put:
Code:
sw.stop()
console.writeline(String.format(The program ran in: {0}ms, _
sw.ElapsedMilliseconds.tostring))
if you want it to the nearest minute do
Code:
dim passedTime as ulong = sw.elapsedMilliseconds mod 60000
console.writeline(String.format(The program ran in: {0} minutes, _
passedTime.tostring))
hope this helps!
Re: how long a program runs
Quote:
Originally Posted by
patplays852
im assuming you mean how long it takes a section of code to run correct?
imports:
Code:
imports system.diagnostics
put this before the code that is taking forever:
Code:
Dim sw as new stopwatch
sw.start()
at the end of the code put:
Code:
sw.stop()
console.writeline(String.format(The program ran in: {0}ms, _
sw.ElapsedMilliseconds.tostring))
if you want it to the nearest minute do
Code:
dim passedTime as ulong = sw.elapsedMilliseconds mod 60000
console.writeline(String.format(The program ran in: {0} minutes, _
passedTime.tostring))
hope this helps!
He could time the entire execution time of the program, provided that the said program will close itself automatically when done.
He'd just need to make a new program, use the stop watch you've provided and combine it with the Process class (there's a WaitForExit method). So he'd start the stopwatch, start the program, wait for exit then stop the stopwatch and see how long it took.
Re: how long a program runs
That is true (I did incorrectly word my statement when i said a section of code), I only really have experience in using this on a button click, I dim it at the start of the sub, then i do my code, and display the time. (which is essentially the "whole" program for what i test.
If he/she needs help implementing it in his/her project I think we need to see some of the code they have.