annotate Implab/Diagnostics/LogicalOperation.cs @ 171:0f70905b4652 ref20160224

Working on regular DFA
author cin
date Thu, 10 Mar 2016 01:19:33 +0300
parents 4c0e5ef99986
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
35
2880242f987a initial log capabilities
cin
parents:
diff changeset
1 using System;
2880242f987a initial log capabilities
cin
parents:
diff changeset
2
2880242f987a initial log capabilities
cin
parents:
diff changeset
3 namespace Implab.Diagnostics {
2880242f987a initial log capabilities
cin
parents:
diff changeset
4 public class LogicalOperation {
92
4c0e5ef99986 rewritten tracing
cin
parents: 35
diff changeset
5 public static readonly LogicalOperation EMPTY = new LogicalOperation("__EMPTY__", null);
4c0e5ef99986 rewritten tracing
cin
parents: 35
diff changeset
6
35
2880242f987a initial log capabilities
cin
parents:
diff changeset
7 readonly LogicalOperation m_parent;
2880242f987a initial log capabilities
cin
parents:
diff changeset
8 readonly string m_name;
2880242f987a initial log capabilities
cin
parents:
diff changeset
9 readonly int m_level;
2880242f987a initial log capabilities
cin
parents:
diff changeset
10 readonly int m_timestamp;
2880242f987a initial log capabilities
cin
parents:
diff changeset
11
2880242f987a initial log capabilities
cin
parents:
diff changeset
12 public LogicalOperation()
2880242f987a initial log capabilities
cin
parents:
diff changeset
13 : this(null, null) {
2880242f987a initial log capabilities
cin
parents:
diff changeset
14 }
2880242f987a initial log capabilities
cin
parents:
diff changeset
15
2880242f987a initial log capabilities
cin
parents:
diff changeset
16 public LogicalOperation(string name, LogicalOperation parent) {
2880242f987a initial log capabilities
cin
parents:
diff changeset
17 m_name = name ?? String.Empty;
2880242f987a initial log capabilities
cin
parents:
diff changeset
18 m_parent = parent;
2880242f987a initial log capabilities
cin
parents:
diff changeset
19
2880242f987a initial log capabilities
cin
parents:
diff changeset
20 m_level = parent == null ? 0 : parent.Level + 1;
2880242f987a initial log capabilities
cin
parents:
diff changeset
21 m_timestamp = Environment.TickCount;
2880242f987a initial log capabilities
cin
parents:
diff changeset
22 }
2880242f987a initial log capabilities
cin
parents:
diff changeset
23
2880242f987a initial log capabilities
cin
parents:
diff changeset
24 public int Duration {
2880242f987a initial log capabilities
cin
parents:
diff changeset
25 get {
2880242f987a initial log capabilities
cin
parents:
diff changeset
26 var dt = Environment.TickCount - m_timestamp;
2880242f987a initial log capabilities
cin
parents:
diff changeset
27 return dt < 0 ? int.MaxValue + dt : dt; // handle overflow
2880242f987a initial log capabilities
cin
parents:
diff changeset
28 }
2880242f987a initial log capabilities
cin
parents:
diff changeset
29 }
2880242f987a initial log capabilities
cin
parents:
diff changeset
30
2880242f987a initial log capabilities
cin
parents:
diff changeset
31 public LogicalOperation Parent {
2880242f987a initial log capabilities
cin
parents:
diff changeset
32 get {
2880242f987a initial log capabilities
cin
parents:
diff changeset
33 return m_parent;
2880242f987a initial log capabilities
cin
parents:
diff changeset
34 }
2880242f987a initial log capabilities
cin
parents:
diff changeset
35 }
2880242f987a initial log capabilities
cin
parents:
diff changeset
36
2880242f987a initial log capabilities
cin
parents:
diff changeset
37 public int Level {
2880242f987a initial log capabilities
cin
parents:
diff changeset
38 get { return m_level; }
2880242f987a initial log capabilities
cin
parents:
diff changeset
39 }
2880242f987a initial log capabilities
cin
parents:
diff changeset
40
2880242f987a initial log capabilities
cin
parents:
diff changeset
41 public string Name {
2880242f987a initial log capabilities
cin
parents:
diff changeset
42 get { return m_name; }
2880242f987a initial log capabilities
cin
parents:
diff changeset
43 }
2880242f987a initial log capabilities
cin
parents:
diff changeset
44 }
2880242f987a initial log capabilities
cin
parents:
diff changeset
45 }