-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathTiming.cs
More file actions
45 lines (41 loc) · 833 Bytes
/
Timing.cs
File metadata and controls
45 lines (41 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Created by SharpDevelop.
* User: Administrator
* Date: 2011-1-17
* Time: 14:26
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Diagnostics;
using System.Threading;
namespace eflayMH_WPF
{
/// <summary>
/// 时间测试
/// </summary>
public class Timing
{
TimeSpan statingTime;
TimeSpan duration;
public Timing()
{
statingTime = new TimeSpan(0);
duration = new TimeSpan(0);
}
public void StopTime()
{
duration = Process.GetCurrentProcess().Threads[0].UserProcessorTime.Subtract(statingTime);
}
public void startTime()
{
GC.Collect();
GC.WaitForPendingFinalizers();
statingTime = Process.GetCurrentProcess().Threads[0].UserProcessorTime;
}
public TimeSpan Result()
{
return duration;
}
}
}