Skip to content

Commit 300111a

Browse files
committed
MetaInfo
1 parent 4e8613b commit 300111a

1 file changed

Lines changed: 171 additions & 72 deletions

File tree

Lines changed: 171 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package engine.metainfo;
22

3+
import java.util.HashMap;
34
import java.util.HashSet;
45

56
import engine.Engine;
@@ -11,7 +12,7 @@
1112
import parse.std.ParseStandard;
1213
import util.trace.TraceAndDataSets;
1314

14-
public class MetaInfoEngine extends Engine<Event>{
15+
public class MetaInfoEngine extends Engine<Event> {
1516

1617
private HashSet<Integer> locationIdSet;
1718
private HashSet<String> threadSet_meta;
@@ -20,19 +21,23 @@ public class MetaInfoEngine extends Engine<Event>{
2021
private HashSet<String> readVariableSet;
2122
private HashSet<String> writeVariableSet;
2223

23-
int eventCount;
24-
int readCount;
25-
int writeCount;
26-
int acquireCount;
27-
int releaseCount;
28-
int forkCount;
29-
int joinCount;
24+
private long eventCount;
25+
private long readCount;
26+
private long writeCount;
27+
private long acquireCount;
28+
private long releaseCount;
29+
private long forkCount;
30+
private long joinCount;
31+
private long beginCount;
32+
private long endCount;
33+
private long branchCount;
34+
private long outermostBeginCount;
35+
private HashMap<String, Integer> txn_depth;
3036

3137
public MetaInfoEngine(ParserType pType, String trace_folder) {
32-
super(pType);
3338

39+
super(pType);
3440
initializeReader(trace_folder);
35-
3641
handlerEvent = new Event();
3742

3843
locationIdSet = new HashSet<Integer> ();
@@ -41,38 +46,46 @@ public MetaInfoEngine(ParserType pType, String trace_folder) {
4146
variableSet_meta = new HashSet<String> ();
4247
readVariableSet = new HashSet<String> ();
4348
writeVariableSet = new HashSet<String> ();
49+
}
50+
51+
public void spitOut() {
52+
System.out.println("Number of locations = " + Integer.toString(locationIdSet.size()));
53+
System.out.println("Number of threads = " + Integer.toString(threadSet_meta.size()));
54+
System.out.println("Number of locks = " + Integer.toString(lockSet_meta.size()));
55+
System.out.println("Number of variables = " + Integer.toString(variableSet_meta.size()));
56+
System.out.println("Number of variables (read) = " + Integer.toString(readVariableSet.size()));
57+
System.out.println("Number of variables (write) = " + Integer.toString(writeVariableSet.size()));
58+
System.out.println();
4459

60+
System.out.println("Number of events = " + Long.toString(eventCount));
61+
System.out.println("Number of read events = " + Long.toString(readCount));
62+
System.out.println("Number of write events = " + Long.toString(writeCount));
63+
System.out.println("Number of reads+writes = " + Long.toString(readCount + writeCount));
64+
System.out.println("Number of acquire events = " + Long.toString(acquireCount));
65+
System.out.println("Number of release events = " + Long.toString(releaseCount));
66+
System.out.println("Number of fork events = " + Long.toString(forkCount));
67+
System.out.println("Number of join events = " + Long.toString(joinCount));
68+
System.out.println("Number of begin events = " + Long.toString(beginCount));
69+
System.out.println("Number of end events = " + Long.toString(endCount));
70+
System.out.println("Number of branch events = " + Long.toString(branchCount));
71+
System.out.println("Number of outermost begin events = " + Long.toString(outermostBeginCount));
72+
}
73+
74+
public void analyzeTrace() {
4575
eventCount = 0;
4676
readCount = 0;
4777
writeCount = 0;
4878
acquireCount = 0;
4979
releaseCount = 0;
5080
forkCount = 0;
5181
joinCount = 0;
52-
}
53-
54-
@Override
55-
protected void initializeReaderRV(String trace_folder){
56-
rvParser = new ParseRVPredict(trace_folder, null);
57-
}
58-
59-
@Override
60-
protected void initializeReaderCSV(String trace_file){
61-
TraceAndDataSets traceAndDataSets = ParseCSV.parse(true, trace_file);
62-
this.trace = traceAndDataSets.getTrace();
63-
}
64-
65-
@Override
66-
protected void initializeReaderSTD(String trace_file) {
67-
stdParser = new ParseStandard(trace_file);
68-
}
69-
70-
@Override
71-
protected void initializeReaderRR(String trace_file) {
72-
rrParser = new ParseRoadRunner(trace_file);
73-
}
82+
beginCount = 0;
83+
endCount = 0;
84+
branchCount = 0;
85+
86+
outermostBeginCount = 0;
87+
txn_depth = new HashMap<String, Integer> ();
7488

75-
public void analyzeTrace() {
7689
if(this.parserType.isRV()){
7790
analyzeTraceRV();
7891
}
@@ -85,13 +98,44 @@ else if(this.parserType.isSTD()){
8598
else if(this.parserType.isRR()){
8699
analyzeTraceRR();
87100
}
101+
spitOut();
102+
}
103+
104+
private void analyzeTraceRV() {
105+
if(rvParser.pathListNotNull()){
106+
while(rvParser.hasNext()){
107+
rvParser.getNextEvent(handlerEvent);
108+
processEvent();
109+
}
110+
}
111+
}
112+
113+
private void analyzeTraceCSV() {
114+
for(int eCount = 0; eCount < trace.getSize(); eCount ++){
115+
handlerEvent = trace.getEventAt(eCount);
116+
processEvent();
117+
}
118+
}
119+
120+
private void analyzeTraceSTD() {
121+
while(stdParser.hasNext()){
122+
stdParser.getNextEvent(handlerEvent);
123+
processEvent();
124+
}
88125
}
89126

90-
public void processEvent(){
127+
private void analyzeTraceRR() {
128+
while(rrParser.checkAndGetNext(handlerEvent)){
129+
processEvent();
130+
}
131+
}
132+
133+
private void processEvent(){
91134
locationIdSet.add((Integer)handlerEvent.getLocId());
92135
threadSet_meta.add(handlerEvent.getThread().getName());
93136

94-
137+
eventCount = eventCount + 1;
138+
95139
if(handlerEvent.getType().isRead()){
96140
readCount = readCount + 1;
97141
readVariableSet.add(handlerEvent.getVariable().getName());
@@ -116,62 +160,117 @@ public void processEvent(){
116160
if(handlerEvent.getType().isJoin()){
117161
joinCount = joinCount + 1;
118162
}
119-
}
120-
121-
public void postAnalysis(){
122-
System.out.println("Number of locations = " + Integer.toString(locationIdSet.size()));
123-
System.out.println("Number of threads = " + Integer.toString(threadSet_meta.size()));
124-
System.out.println("Number of locks = " + Integer.toString(lockSet_meta.size()));
125-
System.out.println("Number of variables = " + Integer.toString(variableSet_meta.size()));
126-
System.out.println("Number of variables (read) = " + Integer.toString(readVariableSet.size()));
127-
System.out.println("Number of variables (write) = " + Integer.toString(writeVariableSet.size()));
128-
System.out.println();
129-
130-
System.out.println("Number of events = " + Integer.toString(eventCount));
131-
System.out.println("Number of read events = " + Integer.toString(readCount));
132-
System.out.println("Number of write events = " + Integer.toString(writeCount));
133-
System.out.println("Number of reads+writes = " + Integer.toString(readCount + writeCount));
134-
System.out.println("Number of acquire events = " + Integer.toString(acquireCount));
135-
System.out.println("Number of release events = " + Integer.toString(releaseCount));
136-
System.out.println("Number of fork events = " + Integer.toString(forkCount));
137-
System.out.println("Number of join events = " + Integer.toString(joinCount));
138-
}
139-
140-
public void analyzeTraceCSV() {
141-
for(eventCount = 0; eventCount < trace.getSize(); eventCount ++){
142-
handlerEvent = trace.getEventAt(eventCount);
143-
processEvent();
163+
if(handlerEvent.getType().isBegin()){
164+
beginCount = beginCount + 1;
165+
166+
String t_name = handlerEvent.getThread().getName();
167+
if(!txn_depth.containsKey(t_name)) {
168+
txn_depth.put(t_name, 0);
169+
}
170+
int curr_depth = txn_depth.get(t_name);
171+
if(curr_depth == 0) {
172+
outermostBeginCount = outermostBeginCount + 1;
173+
}
174+
txn_depth.put(t_name, curr_depth + 1);
175+
}
176+
if(handlerEvent.getType().isEnd()){
177+
endCount = endCount + 1;
178+
String t_name = handlerEvent.getThread().getName();
179+
int curr_depth = txn_depth.get(t_name);
180+
txn_depth.put(t_name, curr_depth - 1);
144181
}
145-
postAnalysis();
146182
}
147-
148-
public void analyzeTraceRV() {
149-
183+
184+
private void analyzeTraceRV(Long limit) {
150185
if(rvParser.pathListNotNull()){
151186
while(rvParser.hasNext()){
152187
rvParser.getNextEvent(handlerEvent);
153-
eventCount = eventCount + 1;
154188
processEvent();
189+
if(eventCount > limit) {
190+
break;
191+
}
192+
}
193+
}
194+
}
195+
196+
private void analyzeTraceCSV(Long limit) {
197+
for(int eCount = 0; eCount < trace.getSize(); eCount ++){
198+
handlerEvent = trace.getEventAt(eCount);
199+
processEvent();
200+
if(eventCount > limit) {
201+
break;
155202
}
156203
}
157-
postAnalysis();
158204
}
159205

160-
public void analyzeTraceSTD() {
206+
private void analyzeTraceSTD(Long limit) {
161207
while(stdParser.hasNext()){
162208
stdParser.getNextEvent(handlerEvent);
163-
eventCount = eventCount + 1;
164209
processEvent();
210+
if(eventCount > limit) {
211+
break;
212+
}
165213
}
166-
postAnalysis();
167214
}
168215

169-
public void analyzeTraceRR() {
216+
private void analyzeTraceRR(Long limit) {
170217
while(rrParser.checkAndGetNext(handlerEvent)){
171-
eventCount = eventCount + 1;
172218
processEvent();
219+
if(eventCount > limit) {
220+
break;
221+
}
222+
}
223+
}
224+
225+
@Override
226+
protected void initializeReaderRV(String trace_folder){
227+
rvParser = new ParseRVPredict(trace_folder, null);
228+
}
229+
230+
@Override
231+
protected void initializeReaderCSV(String trace_file){
232+
TraceAndDataSets traceAndDataSets = ParseCSV.parse(true, trace_file);
233+
this.trace = traceAndDataSets.getTrace();
234+
}
235+
236+
@Override
237+
protected void initializeReaderSTD(String trace_file) {
238+
stdParser = new ParseStandard(trace_file);
239+
}
240+
241+
@Override
242+
protected void initializeReaderRR(String trace_file) {
243+
rrParser = new ParseRoadRunner(trace_file);
244+
}
245+
246+
public void analyzeTrace(Long limit) {
247+
eventCount = 0;
248+
readCount = 0;
249+
writeCount = 0;
250+
acquireCount = 0;
251+
releaseCount = 0;
252+
forkCount = 0;
253+
joinCount = 0;
254+
beginCount = 0;
255+
endCount = 0;
256+
branchCount = 0;
257+
258+
outermostBeginCount = 0;
259+
txn_depth = new HashMap<String, Integer> ();
260+
261+
if(this.parserType.isRV()){
262+
analyzeTraceRV(limit);
263+
}
264+
else if(this.parserType.isCSV()){
265+
analyzeTraceCSV(limit);
266+
}
267+
else if(this.parserType.isSTD()){
268+
analyzeTraceSTD(limit);
269+
}
270+
else if(this.parserType.isRR()){
271+
analyzeTraceRR(limit);
173272
}
174-
postAnalysis();
273+
spitOut();
175274
}
176275

177276
}

0 commit comments

Comments
 (0)