how to know, how much time take method in C# for example, i have label1 and method
public int MakeSome(int a, int b)
{
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
{
// some operation
}
}
return returnIntValue;
}
know, how to know how many milliseconds take MakeSome method, and write value in label1. thanks
You can use the Stopwatch
class:
Stopwatch st = new Stopwatch();
st.Start();
// call MakeSome method...
st.Stop();
Then you can check the st.ElapsedMilliseconds
property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With