Class WinPerfAsmProfiler
- java.lang.Object
-
- org.openjdk.jmh.profile.AbstractPerfAsmProfiler
-
- org.openjdk.jmh.profile.WinPerfAsmProfiler
-
- All Implemented Interfaces:
ExternalProfiler,Profiler
public class WinPerfAsmProfiler extends AbstractPerfAsmProfiler
Windows performance profiler based on "xperf" utility.You must install
Windows Performance Toolkit. Once installed, locate directory withxperf.exefile and either add it toPATHenvironment variable, or assign it toxperf.dirparameter.This profiler counts only
SampledProfileevents. To achieve this, we setxperfproviders toloader+proc_thread+profile. You may optionally savexperfbinary or parsed outputs usingsavePerfBinorsavePerfparameters respectively. If you do so and want to log more events, you can usexperf.providersparameter to override providers. However, you must specifyloader,proc_threadandprofileproviders anyway. Otherwise sample events will not be generated and profiler will show nothing.By default JDK distributive do not have debug symbols. If you want to analyze JVM internals, you must build OpenJDK on your own. Once built, go to
bin/serverdirectory and unpackjvm.diz. Now you havejvm.pdbfile with JVM debug symbols. Finally, you must assign debug symbols directory tosymbol.dirparameter.This profiler behaves differently comparing to it's Linux counterpart
LinuxPerfAsmProfiler. Linux profiler employsperfutility which can be used to profile a single process. Therefore, Linux profiler wraps forked JVM command line. In contrast,xperfcannot profile only a single process. It have-PidNewProcessargument, but it's sole purpose is to start profiling before the process is started, so that one can be sure that none events generated by this process are missed. It does not filter events from other processes anyhow. For this reason, this profiler doesn't alter forked JVM startup command. Instead, it startsxperfrecording inbeforeTrial(BenchmarkParams)method, and stops inExternalProfiler.afterTrial(org.openjdk.jmh.results.BenchmarkResult, long, java.io.File, java.io.File). This leaves possibility to run this profiler in conjunction with some other profiler requiring startup command alteration.For this reason the profiler must know PID of forked JVM process.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.openjdk.jmh.profile.AbstractPerfAsmProfiler
AbstractPerfAsmProfiler.PerfEvents
-
-
Field Summary
-
Fields inherited from class org.openjdk.jmh.profile.AbstractPerfAsmProfiler
hsLog, perfBinData, perfParsedData, requestedEventNames, set
-
-
Constructor Summary
Constructors Constructor Description WinPerfAsmProfiler(String initLine)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<String>addJVMInvokeOptions(BenchmarkParams params)Prepend JVM invocation with these commands.protected voidaddMyOptions(joptsimple.OptionParser parser)Collection<? extends Result>afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr)Run this code after the trial is done.voidbeforeTrial(BenchmarkParams params)Run this code before starting the trial.StringgetDescription()Human-readable one-line description of the profiler.protected voidparseEvents()Parse profiler events from binary to text form.protected StringperfBinaryExtension()Get perf binary data extension (optional).protected AbstractPerfAsmProfiler.PerfEventsreadEvents(double skipMs, double lenMs)Read parsed events.-
Methods inherited from class org.openjdk.jmh.profile.AbstractPerfAsmProfiler
addJVMOptions, allowPrintErr, allowPrintOut, stripEventNames
-
-
-
-
Constructor Detail
-
WinPerfAsmProfiler
public WinPerfAsmProfiler(String initLine) throws ProfilerException
- Throws:
ProfilerException
-
-
Method Detail
-
addMyOptions
protected void addMyOptions(joptsimple.OptionParser parser)
- Specified by:
addMyOptionsin classAbstractPerfAsmProfiler
-
addJVMInvokeOptions
public Collection<String> addJVMInvokeOptions(BenchmarkParams params)
Description copied from interface:ExternalProfilerPrepend JVM invocation with these commands.- Parameters:
params- benchmark parameters used for current launch- Returns:
- commands to prepend for JVM launch
-
beforeTrial
public void beforeTrial(BenchmarkParams params)
Description copied from interface:ExternalProfilerRun this code before starting the trial. This method will execute before starting the benchmark JVM.- Specified by:
beforeTrialin interfaceExternalProfiler- Overrides:
beforeTrialin classAbstractPerfAsmProfiler- Parameters:
params- benchmark parameters used for current launch
-
afterTrial
public Collection<? extends Result> afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr)
Description copied from interface:ExternalProfilerRun this code after the trial is done. This method will execute after benchmark JVM had stopped.- Specified by:
afterTrialin interfaceExternalProfiler- Overrides:
afterTrialin classAbstractPerfAsmProfiler- Parameters:
br- benchmark result that was the result of the trialpid- pid that the forked JVM hadstdOut- file containing the standard output from the benchmark JVMstdErr- file containing the standard error from the benchmark JVM- Returns:
- profiler results
-
getDescription
public String getDescription()
Description copied from interface:ProfilerHuman-readable one-line description of the profiler.- Returns:
- description
-
parseEvents
protected void parseEvents()
Description copied from class:AbstractPerfAsmProfilerParse profiler events from binary to text form.- Specified by:
parseEventsin classAbstractPerfAsmProfiler
-
readEvents
protected AbstractPerfAsmProfiler.PerfEvents readEvents(double skipMs, double lenMs)
Description copied from class:AbstractPerfAsmProfilerRead parsed events.- Specified by:
readEventsin classAbstractPerfAsmProfiler- Parameters:
skipMs- Milliseconds to skip.lenMs- Milliseconds to capture after skip- Returns:
- Events.
-
perfBinaryExtension
protected String perfBinaryExtension()
Description copied from class:AbstractPerfAsmProfilerGet perf binary data extension (optional).- Specified by:
perfBinaryExtensionin classAbstractPerfAsmProfiler- Returns:
- Extension.
-
-