35
|
1 using System;
|
|
2 using System.Collections.Generic;
|
|
3 using System.Linq;
|
|
4 using System.Text;
|
|
5 using System.Threading.Tasks;
|
|
6
|
|
7 namespace Implab.Diagnostics {
|
|
8 public class LogicalOperation {
|
|
9 readonly LogicalOperation m_parent;
|
|
10 readonly string m_name;
|
|
11 readonly int m_level;
|
|
12 readonly int m_timestamp;
|
|
13
|
|
14 public LogicalOperation()
|
|
15 : this(null, null) {
|
|
16 }
|
|
17
|
|
18 public LogicalOperation(string name, LogicalOperation parent) {
|
|
19 m_name = name ?? String.Empty;
|
|
20 m_parent = parent;
|
|
21
|
|
22 m_level = parent == null ? 0 : parent.Level + 1;
|
|
23 m_timestamp = Environment.TickCount;
|
|
24 }
|
|
25
|
|
26 public int Duration {
|
|
27 get {
|
|
28 var dt = Environment.TickCount - m_timestamp;
|
|
29 return dt < 0 ? int.MaxValue + dt : dt; // handle overflow
|
|
30 }
|
|
31 }
|
|
32
|
|
33 public LogicalOperation Parent {
|
|
34 get {
|
|
35 return m_parent;
|
|
36 }
|
|
37 }
|
|
38
|
|
39 public int Level {
|
|
40 get { return m_level; }
|
|
41 }
|
|
42
|
|
43 public string Name {
|
|
44 get { return m_name; }
|
|
45 }
|
|
46 }
|
|
47 }
|