1 |
torben |
2164 |
using System;
|
2 |
|
|
using System.Collections.Generic;
|
3 |
|
|
using System.Text;
|
4 |
|
|
|
5 |
|
|
namespace DaoCommon
|
6 |
|
|
{
|
7 |
|
|
public class ElapsedTimer
|
8 |
|
|
{
|
9 |
|
|
long start;
|
10 |
|
|
|
11 |
|
|
public ElapsedTimer()
|
12 |
|
|
{
|
13 |
|
|
startTimer(); //Constructor also starts the timer
|
14 |
|
|
}
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
public void startTimer()
|
18 |
|
|
{
|
19 |
|
|
start = DateTime.Now.Ticks;
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
public void stopAndPrint(string msg)
|
23 |
|
|
{
|
24 |
|
|
long stop = DateTime.Now.Ticks;
|
25 |
|
|
|
26 |
|
|
long elapsed = (stop - start) / 10000; //omreg tidsforskel til millisekunder
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
Console.WriteLine( msg + " took " + elapsed + " milliseconds ");
|
30 |
|
|
|
31 |
|
|
startTimer(); //when done reset timer
|
32 |
|
|
}
|
33 |
|
|
}
|
34 |
|
|
}
|