]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/profiling/BranchPoint.java
Sync git svn branch with SVN repository r33249.
[simantics/platform.git] / bundles / org.simantics.scl.runtime / src / org / simantics / scl / runtime / profiling / BranchPoint.java
1 package org.simantics.scl.runtime.profiling;
2
3 public class BranchPoint {
4     public static final BranchPoint[] EMPTY_ARRAY = new BranchPoint[0];
5     
6     private final long location;
7     private final int codeSize;
8     private final BranchPoint[] children;
9     
10     public int visitCounter;
11
12     public BranchPoint(long location, int codeSize, BranchPoint[] children) {
13         this.location = location;
14         this.codeSize = codeSize;
15         this.children = children;
16     }
17     
18     public void resetVisitCountersRecursively() {
19         visitCounter = 0;
20         for(BranchPoint branchPoint : getChildren())
21             branchPoint.resetVisitCountersRecursively();
22     }
23
24     public long getLocation() {
25         return location;
26     }
27
28     public int getCodeSize() {
29         return codeSize;
30     }
31     
32     public int getVisitCounter() {
33         return visitCounter;
34     }
35
36     public void incrementVisitCounter(int amount) {
37         visitCounter = visitCounter + amount;
38     }
39
40     public BranchPoint[] getChildren() {
41         return children;
42     }
43
44     @Override
45     public String toString() {
46         StringBuilder sb = new StringBuilder();
47         sb.append("BP[visitCounter=").append(visitCounter).append(", codeSize=").append(codeSize).append(", location=").append(location);
48         if (children.length > 0)
49             sb.append(", children=").append(children.length);
50         sb.append("]");
51         return sb.toString();
52     }
53
54 }