Search in sources :

Example 1 with Profile

use of com.oracle.truffle.tools.chromeinspector.types.Profile in project graal by oracle.

the class TruffleProfiler method getProfile.

private Params getProfile(Collection<ProfilerNode<CPUSampler.Payload>> rootProfilerNodes, long idleHitCount, long startTime, long endTime) {
    Map<ProfilerNode<CPUSampler.Payload>, Integer> node2id = new HashMap<>();
    List<ProfileNode> nodes = new ArrayList<>();
    List<Profile.TimeLineItem> timeLine = new ArrayList<>();
    int[] counter = { 1 };
    ProfileNode root = new ProfileNode(counter[0]++, new RuntimeCallFrame("(root)", 0, "", 0, 0), idleHitCount);
    nodes.add(root);
    fillChildren(root, rootProfilerNodes, node2id, nodes, timeLine, counter);
    Collections.sort(timeLine, (item1, item2) -> Long.compare(item1.getTimestamp(), item2.getTimestamp()));
    JSONObject json = new JSONObject();
    json.put("profile", new Profile(nodes.toArray(new ProfileNode[nodes.size()]), startTime, endTime, timeLine.toArray(new Profile.TimeLineItem[timeLine.size()])).toJSON());
    return new Params(json);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) Params(com.oracle.truffle.tools.chromeinspector.commands.Params) RuntimeCallFrame(com.oracle.truffle.tools.chromeinspector.types.RuntimeCallFrame) ScriptTypeProfile(com.oracle.truffle.tools.chromeinspector.types.ScriptTypeProfile) Profile(com.oracle.truffle.tools.chromeinspector.types.Profile) ProfilerNode(com.oracle.truffle.tools.profiler.ProfilerNode) JSONObject(org.json.JSONObject) ProfileNode(com.oracle.truffle.tools.chromeinspector.types.ProfileNode) CPUSampler(com.oracle.truffle.tools.profiler.CPUSampler)

Aggregations

Params (com.oracle.truffle.tools.chromeinspector.commands.Params)1 Profile (com.oracle.truffle.tools.chromeinspector.types.Profile)1 ProfileNode (com.oracle.truffle.tools.chromeinspector.types.ProfileNode)1 RuntimeCallFrame (com.oracle.truffle.tools.chromeinspector.types.RuntimeCallFrame)1 ScriptTypeProfile (com.oracle.truffle.tools.chromeinspector.types.ScriptTypeProfile)1 CPUSampler (com.oracle.truffle.tools.profiler.CPUSampler)1 ProfilerNode (com.oracle.truffle.tools.profiler.ProfilerNode)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 JSONObject (org.json.JSONObject)1