org.openqa.selenium.devtools.v85.profiler.Profiler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of selenium-devtools-v85 Show documentation
Show all versions of selenium-devtools-v85 Show documentation
Selenium automates browsers. That's it! What you do with that power is entirely up to you.
package org.openqa.selenium.devtools.v85.profiler;
import org.openqa.selenium.Beta;
import org.openqa.selenium.devtools.Command;
import org.openqa.selenium.devtools.Event;
import org.openqa.selenium.devtools.ConverterFunctions;
import com.google.common.collect.ImmutableMap;
import org.openqa.selenium.json.JsonInput;
public class Profiler {
public static Command disable() {
ImmutableMap.Builder params = ImmutableMap.builder();
return new Command<>("Profiler.disable", params.build());
}
public static Command enable() {
ImmutableMap.Builder params = ImmutableMap.builder();
return new Command<>("Profiler.enable", params.build());
}
/**
* Collect coverage data for the current isolate. The coverage data may be incomplete due to
* garbage collection.
*/
public static Command> getBestEffortCoverage() {
ImmutableMap.Builder params = ImmutableMap.builder();
return new Command<>("Profiler.getBestEffortCoverage", params.build(), ConverterFunctions.map("result", new com.google.common.reflect.TypeToken>() {
}.getType()));
}
/**
* Changes CPU profiler sampling interval. Must be called before CPU profiles recording started.
*/
public static Command setSamplingInterval(java.lang.Integer interval) {
java.util.Objects.requireNonNull(interval, "interval is required");
ImmutableMap.Builder params = ImmutableMap.builder();
params.put("interval", interval);
return new Command<>("Profiler.setSamplingInterval", params.build());
}
public static Command start() {
ImmutableMap.Builder params = ImmutableMap.builder();
return new Command<>("Profiler.start", params.build());
}
/**
* Enable precise code coverage. Coverage data for JavaScript executed before enabling precise code
* coverage may be incomplete. Enabling prevents running optimized code and resets execution
* counters.
*/
public static Command startPreciseCoverage(java.util.Optional callCount, java.util.Optional detailed, java.util.Optional allowTriggeredUpdates) {
ImmutableMap.Builder params = ImmutableMap.builder();
callCount.ifPresent(p -> params.put("callCount", p));
detailed.ifPresent(p -> params.put("detailed", p));
allowTriggeredUpdates.ifPresent(p -> params.put("allowTriggeredUpdates", p));
return new Command<>("Profiler.startPreciseCoverage", params.build(), ConverterFunctions.map("timestamp", java.lang.Number.class));
}
/**
* Enable type profile.
*/
@Beta()
public static Command startTypeProfile() {
ImmutableMap.Builder params = ImmutableMap.builder();
return new Command<>("Profiler.startTypeProfile", params.build());
}
public static Command stop() {
ImmutableMap.Builder params = ImmutableMap.builder();
return new Command<>("Profiler.stop", params.build(), ConverterFunctions.map("profile", org.openqa.selenium.devtools.v85.profiler.model.Profile.class));
}
/**
* Disable precise code coverage. Disabling releases unnecessary execution count records and allows
* executing optimized code.
*/
public static Command stopPreciseCoverage() {
ImmutableMap.Builder params = ImmutableMap.builder();
return new Command<>("Profiler.stopPreciseCoverage", params.build());
}
/**
* Disable type profile. Disabling releases type profile data collected so far.
*/
@Beta()
public static Command stopTypeProfile() {
ImmutableMap.Builder params = ImmutableMap.builder();
return new Command<>("Profiler.stopTypeProfile", params.build());
}
public static class TakePreciseCoverageResponse {
private final java.util.List result;
private final java.lang.Number timestamp;
public TakePreciseCoverageResponse(java.util.List result, java.lang.Number timestamp) {
this.result = java.util.Objects.requireNonNull(result, "result is required");
this.timestamp = java.util.Objects.requireNonNull(timestamp, "timestamp is required");
}
/**
* Coverage data for the current isolate.
*/
public java.util.List getResult() {
return result;
}
/**
* Monotonically increasing time (in seconds) when the coverage update was taken in the backend.
*/
public java.lang.Number getTimestamp() {
return timestamp;
}
private static TakePreciseCoverageResponse fromJson(JsonInput input) {
java.util.List result = null;
java.lang.Number timestamp = 0;
input.beginObject();
while (input.hasNext()) {
switch(input.nextName()) {
case "result":
result = input.read(new com.google.common.reflect.TypeToken>() {
}.getType());
break;
case "timestamp":
timestamp = input.nextNumber();
break;
default:
input.skipValue();
break;
}
}
input.endObject();
return new TakePreciseCoverageResponse(result, timestamp);
}
}
/**
* Collect coverage data for the current isolate, and resets execution counters. Precise code
* coverage needs to have started.
*/
public static Command takePreciseCoverage() {
ImmutableMap.Builder params = ImmutableMap.builder();
return new Command<>("Profiler.takePreciseCoverage", params.build(), input -> input.read(org.openqa.selenium.devtools.v85.profiler.Profiler.TakePreciseCoverageResponse.class));
}
/**
* Collect type profile.
*/
@Beta()
public static Command> takeTypeProfile() {
ImmutableMap.Builder params = ImmutableMap.builder();
return new Command<>("Profiler.takeTypeProfile", params.build(), ConverterFunctions.map("result", new com.google.common.reflect.TypeToken>() {
}.getType()));
}
/**
* Enable run time call stats collection.
*/
@Beta()
public static Command enableRuntimeCallStats() {
ImmutableMap.Builder params = ImmutableMap.builder();
return new Command<>("Profiler.enableRuntimeCallStats", params.build());
}
/**
* Disable run time call stats collection.
*/
@Beta()
public static Command disableRuntimeCallStats() {
ImmutableMap.Builder params = ImmutableMap.builder();
return new Command<>("Profiler.disableRuntimeCallStats", params.build());
}
/**
* Retrieve run time call stats.
*/
@Beta()
public static Command> getRuntimeCallStats() {
ImmutableMap.Builder params = ImmutableMap.builder();
return new Command<>("Profiler.getRuntimeCallStats", params.build(), ConverterFunctions.map("result", new com.google.common.reflect.TypeToken>() {
}.getType()));
}
public static Event consoleProfileFinished() {
return new Event<>("Profiler.consoleProfileFinished", input -> input.read(org.openqa.selenium.devtools.v85.profiler.model.ConsoleProfileFinished.class));
}
public static Event consoleProfileStarted() {
return new Event<>("Profiler.consoleProfileStarted", input -> input.read(org.openqa.selenium.devtools.v85.profiler.model.ConsoleProfileStarted.class));
}
public static Event preciseCoverageDeltaUpdate() {
return new Event<>("Profiler.preciseCoverageDeltaUpdate", input -> input.read(org.openqa.selenium.devtools.v85.profiler.model.PreciseCoverageDeltaUpdate.class));
}
}