-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v19 (Traces): Print (partial) implementation executions.
- Loading branch information
Showing
13 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package org.kuppe; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Paths; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
|
||
import jdk.jfr.Category; | ||
import jdk.jfr.Label; | ||
import jdk.jfr.Name; | ||
import jdk.jfr.StackTrace; | ||
import jdk.jfr.consumer.RecordedEvent; | ||
import jdk.jfr.consumer.RecordingFile; | ||
|
||
public class App2TLA { | ||
|
||
@Label("Buffer Deq Operation") | ||
@Name("app.bufDeqOp") | ||
@Category("MyApp") | ||
@StackTrace(false) | ||
static class BufferDeqEvent extends jdk.jfr.Event { | ||
} | ||
|
||
@Label("Buffer Deq Operation") | ||
@Name("app.bufEnqOp") | ||
@Category("MyApp") | ||
@StackTrace(false) | ||
static class BufferEnqEvent extends jdk.jfr.Event { | ||
} | ||
|
||
@Label("Buffer Wait Operation") | ||
@Name("app.bufWaitOp") | ||
@Category("MyApp") | ||
@StackTrace(false) | ||
static class BufferWaitEvent extends jdk.jfr.Event { | ||
|
||
@Label("(p)roducer or (c)onsumer") | ||
String type; | ||
|
||
public BufferWaitEvent(String type) { | ||
this.type = type; | ||
} | ||
} | ||
|
||
public static void main(final String[] args) throws IOException { | ||
final List<RecordedEvent> recordedEvents = RecordingFile | ||
.readAllEvents(Paths.get(args.length > 0 ? args[0] : "app.jfr")); | ||
|
||
// Order events chronologically based on the system's clock (that hopefully has | ||
// sufficient precision). | ||
// TODO: Logical clock instead of real/global clock. | ||
recordedEvents.sort(new Comparator<RecordedEvent>() { | ||
@Override | ||
public int compare(RecordedEvent o1, RecordedEvent o2) { | ||
return o1.getStartTime().compareTo(o2.getStartTime()); | ||
} | ||
}); | ||
|
||
printTrace(recordedEvents); | ||
} | ||
|
||
private static void printTrace(final List<RecordedEvent> events) { | ||
// Format each step in the execution as a TLA+ record. | ||
for (RecordedEvent event : events) { | ||
if (event.getEventType().getName().equals("app.bufDeqOp")) { | ||
System.out.printf("[ op |-> \"d\" ],\n"); | ||
} else if (event.getEventType().getName().equals("app.bufEnqOp")) { | ||
System.out.printf("[ op |-> \"e\" ],\n"); | ||
} else if (event.getEventType().getName().equals("app.bufWaitOp")) { | ||
System.out.printf("[ op |-> \"w\", waiter |-> \"%s\" ],\n", event.getString("type")); | ||
} | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.