com.hubspot.chrome.devtools.client.core.performance.Performance Maven / Gradle / Ivy
package com.hubspot.chrome.devtools.client.core.performance;
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 java.util.List;
import java.util.concurrent.CompletableFuture;
public final class Performance {
ChromeSessionCore chromeSession;
ObjectMapper objectMapper;
public Performance(ChromeSessionCore chromeSession, ObjectMapper objectMapper) {
this.chromeSession = chromeSession;
this.objectMapper = objectMapper;
}
/**
* Disable collecting and reporting metrics.
*/
public void disable() {
ChromeRequest chromeRequest = new ChromeRequest("Performance.disable");
chromeSession.send(chromeRequest);
}
/**
* Disable collecting and reporting metrics.
*/
public void disableAsync() {
ChromeRequest chromeRequest = new ChromeRequest("Performance.disable");
chromeSession.sendAsync(chromeRequest);
}
/**
* Enable collecting and reporting metrics.
*/
public void enable() {
ChromeRequest chromeRequest = new ChromeRequest("Performance.enable");
chromeSession.send(chromeRequest);
}
/**
* Enable collecting and reporting metrics.
*/
public void enableAsync() {
ChromeRequest chromeRequest = new ChromeRequest("Performance.enable");
chromeSession.sendAsync(chromeRequest);
}
/**
* Retrieve current values of run-time metrics.
*/
public List getMetrics() {
ChromeRequest chromeRequest = new ChromeRequest("Performance.getMetrics");
return chromeSession.send(chromeRequest, new TypeReference>(){});
}
/**
* Retrieve current values of run-time metrics.
*/
public CompletableFuture> getMetricsAsync() {
ChromeRequest chromeRequest = new ChromeRequest("Performance.getMetrics");
return chromeSession.sendAsync(chromeRequest, new TypeReference>(){});
}
}