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 java.util.Map;
import java.util.LinkedHashMap;
import org.openqa.selenium.json.JsonInput;
public class Profiler {
public static Command disable() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("Profiler.disable", Map.copyOf(params));
}
public static Command enable() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("Profiler.enable", Map.copyOf(params));
}
/**
* Collect coverage data for the current isolate. The coverage data may be incomplete due to
* garbage collection.
*/
public static Command> getBestEffortCoverage() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("Profiler.getBestEffortCoverage", Map.copyOf(params), ConverterFunctions.map("result", input -> input.readArray(org.openqa.selenium.devtools.v85.profiler.model.ScriptCoverage.class)));
}
/**
* 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");
LinkedHashMap params = new LinkedHashMap<>();
params.put("interval", interval);
return new Command<>("Profiler.setSamplingInterval", Map.copyOf(params));
}
public static Command start() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("Profiler.start", Map.copyOf(params));
}
/**
* 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) {
LinkedHashMap params = new LinkedHashMap<>();
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", Map.copyOf(params), ConverterFunctions.map("timestamp", java.lang.Number.class));
}
/**
* Enable type profile.
*/
@Beta()
public static Command startTypeProfile() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("Profiler.startTypeProfile", Map.copyOf(params));
}
public static Command stop() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("Profiler.stop", Map.copyOf(params), 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() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("Profiler.stopPreciseCoverage", Map.copyOf(params));
}
/**
* Disable type profile. Disabling releases type profile data collected so far.
*/
@Beta()
public static Command stopTypeProfile() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("Profiler.stopTypeProfile", Map.copyOf(params));
}
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.readArray(org.openqa.selenium.devtools.v85.profiler.model.ScriptCoverage.class);
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() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("Profiler.takePreciseCoverage", Map.copyOf(params), input -> input.read(org.openqa.selenium.devtools.v85.profiler.Profiler.TakePreciseCoverageResponse.class));
}
/**
* Collect type profile.
*/
@Beta()
public static Command> takeTypeProfile() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("Profiler.takeTypeProfile", Map.copyOf(params), ConverterFunctions.map("result", input -> input.readArray(org.openqa.selenium.devtools.v85.profiler.model.ScriptTypeProfile.class)));
}
/**
* Enable run time call stats collection.
*/
@Beta()
public static Command enableRuntimeCallStats() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("Profiler.enableRuntimeCallStats", Map.copyOf(params));
}
/**
* Disable run time call stats collection.
*/
@Beta()
public static Command disableRuntimeCallStats() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("Profiler.disableRuntimeCallStats", Map.copyOf(params));
}
/**
* Retrieve run time call stats.
*/
@Beta()
public static Command> getRuntimeCallStats() {
LinkedHashMap params = new LinkedHashMap<>();
return new Command<>("Profiler.getRuntimeCallStats", Map.copyOf(params), ConverterFunctions.map("result", input -> input.readArray(org.openqa.selenium.devtools.v85.profiler.model.CounterInfo.class)));
}
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));
}
}