Click here to Skip to main content
15,885,953 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
I have a three algorithms implemented in c#, i want to compare these algorithm on the basis of the execution time, please give me the code that compare these algorithm in c# windows form?? an how can i compare it?? i really need it
Posted
Comments
[no name] 21-Sep-14 9:06am    
http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch(v=vs.110).aspx

You can use Stopwatch [^]for this. Something like this:

C#
var watch = Stopwatch.StartNew();
// the code that you want to measure comes here
watch.Stop();
var elapsedMs = watch.ElapsedMilliseconds;
 
Share this answer
 
Comments
Member 11063279 21-Sep-14 9:12am    
but this will give the zero result every time, please explain me ??
Manas Bhardwaj 21-Sep-14 9:14am    
Did you replace the comment with the method call which you want measure?
Member 11063279 21-Sep-14 9:32am    
yup i have changed but it gives the different answer , more ever for long string it's start giving short answer. is it giving answer in nano second??
Manas Bhardwaj 21-Sep-14 9:40am    
In MilliSeconds. I think the property name itself is self explanatory.
Sergey Alexandrovich Kryukov 21-Sep-14 13:42pm    
Real accuracy is better than that...
—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900