com.hubspot.chrome.devtools.client.core.heapprofiler.HeapProfiler Maven / Gradle / Ivy
package com.hubspot.chrome.devtools.client.core.heapprofiler;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hubspot.chrome.devtools.base.ChromeRequest;
import com.hubspot.chrome.devtools.base.ChromeSessionCore;
import com.hubspot.chrome.devtools.client.core.runtime.RemoteObject;
import com.hubspot.chrome.devtools.client.core.runtime.RemoteObjectId;
import java.util.concurrent.CompletableFuture;
public final class HeapProfiler {
ChromeSessionCore chromeSession;
ObjectMapper objectMapper;
public HeapProfiler(ChromeSessionCore chromeSession, ObjectMapper objectMapper) {
this.chromeSession = chromeSession;
this.objectMapper = objectMapper;
}
/**
* Enables console to refer to the node with given id via x (see Command Line API for more details
* x functions).
*
* @param heapObjectId Heap snapshot object id to be accessible by means of x command line API.
*/
public void addInspectedHeapObject(HeapSnapshotObjectId heapObjectId) {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.addInspectedHeapObject");
chromeRequest
.putParams("heapObjectId", heapObjectId);
chromeSession.send(chromeRequest);
}
/**
* Enables console to refer to the node with given id via x (see Command Line API for more details
* x functions).
*
* @param heapObjectId Heap snapshot object id to be accessible by means of x command line API.
*/
public void addInspectedHeapObjectAsync(HeapSnapshotObjectId heapObjectId) {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.addInspectedHeapObject");
chromeRequest
.putParams("heapObjectId", heapObjectId);
chromeSession.sendAsync(chromeRequest);
}
public void collectGarbage() {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.collectGarbage");
chromeSession.send(chromeRequest);
}
public void collectGarbageAsync() {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.collectGarbage");
chromeSession.sendAsync(chromeRequest);
}
public void disable() {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.disable");
chromeSession.send(chromeRequest);
}
public void disableAsync() {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.disable");
chromeSession.sendAsync(chromeRequest);
}
public void enable() {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.enable");
chromeSession.send(chromeRequest);
}
public void enableAsync() {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.enable");
chromeSession.sendAsync(chromeRequest);
}
public HeapSnapshotObjectId getHeapObjectId(RemoteObjectId objectId) {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.getHeapObjectId");
chromeRequest
.putParams("objectId", objectId);
return chromeSession.send(chromeRequest, new TypeReference(){});
}
public CompletableFuture getHeapObjectIdAsync(RemoteObjectId objectId) {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.getHeapObjectId");
chromeRequest
.putParams("objectId", objectId);
return chromeSession.sendAsync(chromeRequest, new TypeReference(){});
}
public RemoteObject getObjectByHeapObjectId(HeapSnapshotObjectId objectId, String objectGroup) {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.getObjectByHeapObjectId");
chromeRequest
.putParams("objectId", objectId)
.putParams("objectGroup", objectGroup);
return chromeSession.send(chromeRequest, new TypeReference(){});
}
public CompletableFuture getObjectByHeapObjectIdAsync(HeapSnapshotObjectId objectId,
String objectGroup) {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.getObjectByHeapObjectId");
chromeRequest
.putParams("objectId", objectId)
.putParams("objectGroup", objectGroup);
return chromeSession.sendAsync(chromeRequest, new TypeReference(){});
}
public SamplingHeapProfile getSamplingProfile() {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.getSamplingProfile");
return chromeSession.send(chromeRequest, new TypeReference(){});
}
public CompletableFuture getSamplingProfileAsync() {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.getSamplingProfile");
return chromeSession.sendAsync(chromeRequest, new TypeReference(){});
}
public void startSampling(Number samplingInterval) {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.startSampling");
chromeRequest
.putParams("samplingInterval", samplingInterval);
chromeSession.send(chromeRequest);
}
public void startSamplingAsync(Number samplingInterval) {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.startSampling");
chromeRequest
.putParams("samplingInterval", samplingInterval);
chromeSession.sendAsync(chromeRequest);
}
public void startTrackingHeapObjects(Boolean trackAllocations) {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.startTrackingHeapObjects");
chromeRequest
.putParams("trackAllocations", trackAllocations);
chromeSession.send(chromeRequest);
}
public void startTrackingHeapObjectsAsync(Boolean trackAllocations) {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.startTrackingHeapObjects");
chromeRequest
.putParams("trackAllocations", trackAllocations);
chromeSession.sendAsync(chromeRequest);
}
public SamplingHeapProfile stopSampling() {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.stopSampling");
return chromeSession.send(chromeRequest, new TypeReference(){});
}
public CompletableFuture stopSamplingAsync() {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.stopSampling");
return chromeSession.sendAsync(chromeRequest, new TypeReference(){});
}
public void stopTrackingHeapObjects(Boolean reportProgress) {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.stopTrackingHeapObjects");
chromeRequest
.putParams("reportProgress", reportProgress);
chromeSession.send(chromeRequest);
}
public void stopTrackingHeapObjectsAsync(Boolean reportProgress) {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.stopTrackingHeapObjects");
chromeRequest
.putParams("reportProgress", reportProgress);
chromeSession.sendAsync(chromeRequest);
}
public void takeHeapSnapshot(Boolean reportProgress) {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.takeHeapSnapshot");
chromeRequest
.putParams("reportProgress", reportProgress);
chromeSession.send(chromeRequest);
}
public void takeHeapSnapshotAsync(Boolean reportProgress) {
ChromeRequest chromeRequest = new ChromeRequest("HeapProfiler.takeHeapSnapshot");
chromeRequest
.putParams("reportProgress", reportProgress);
chromeSession.sendAsync(chromeRequest);
}
}