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