Here’s there Timer class:
public class Timer
{
long _start;
long _stop;
public void Start()
{
_start = GetTimeInMilliseconds();
}
public void Stop()
{
_stop = GetTimeInMilliseconds();
}
public long TimeElapsed
{
get { return _stop - _start; }
}
private long GetTimeInMilliseconds()
{
return DateTime.Now.Hour * 60 * 60 * 1000
+ DateTime.Now.Minute * 60 * 1000
+ DateTime.Now.Second * 1000
+ DateTime.Now.Millisecond;
}
}
In case you’re interested in performance difference between SqlDataReader and DataTableReader. Here’re my findings:
On single CPU machine SqlDataReader was faster and it of course was expected. However, on double CPU machine DataTableReader was slightly faster and this was a pleasant surprise for me.
2 comments:
If you're using .Net 2.0, you can use the Stopwatch class:
http://msdn2.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx
chuck, thanks a lot. It definitely would work. If I new about Stopwatch class, I would use it instead of writing my own timer.
Post a Comment