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.exe
file and either add it toPATH
environment variable, or set it tojmh.perfasm.xperf.dir
system property.This profiler counts only
SampledProfile
events. To achieve this, we setxperf
providers toloader+proc_thread+profile
. You may optionally savexperf
binary or parsed outputs usingjmh.perfasm.savePerfBin
orjmh.perfasm.savePerf
system properties respectively. If you do so and want to log more events, you can usejmh.perfasm.xperf.providers
system property to override providers. However, you must specifyloader
,proc_thread
andprofile
providers 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/server
directory and unpackjvm.diz
. Now you havejvm.pdb
file with JVM debug symbols. Finally, you must set debug symbols directory tojmh.perfasm.symbol.dir
system property.This profiler behaves differently comparing to it's Linux counterpart
LinuxPerfAsmProfiler
. Linux profiler employsperf
utility which can be used to profile a single process. Therefore, Linux profiler wraps forked JVM command line. In contrast,xperf
cannot profile only a single process. It have-PidNewProcess
argument, 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 startsxperf
recording 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.ASMLine, AbstractPerfAsmProfiler.Assembly, AbstractPerfAsmProfiler.GeneratedRegion, AbstractPerfAsmProfiler.MethodDesc, AbstractPerfAsmProfiler.NativeRegion, AbstractPerfAsmProfiler.PerfEvents, AbstractPerfAsmProfiler.Region, AbstractPerfAsmProfiler.UnknownRegion
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
MSG_UNABLE_START
private static java.lang.String
MSG_UNABLE_STOP
private joptsimple.OptionSpec<java.lang.String>
optSymbolDir
private joptsimple.OptionSpec<java.lang.String>
optXperfDir
private joptsimple.OptionSpec<java.lang.String>
optXperfProviders
private java.lang.String
path
private java.lang.String
pid
PID.private java.lang.String
symbolDir
private java.lang.String
xperfProviders
-
Fields inherited from class org.openjdk.jmh.profile.AbstractPerfAsmProfiler
hsLog, perfBinData, perfParsedData, requestedEventNames, set
-
-
Constructor Summary
Constructors Constructor Description WinPerfAsmProfiler(java.lang.String initLine)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Collection<java.lang.String>
addJVMInvokeOptions(BenchmarkParams params)
Prepend JVM invocation with these commands.protected void
addMyOptions(joptsimple.OptionParser parser)
java.util.Collection<? extends Result>
afterTrial(BenchmarkResult br, long pid, java.io.File stdOut, java.io.File stdErr)
Run this code after the trial is done.void
beforeTrial(BenchmarkParams params)
Run this code before starting the trial.java.lang.String
getDescription()
Human-readable one-line description of the profiler.protected void
parseEvents()
Parse profiler events from binary to text form.protected java.lang.String
perfBinaryExtension()
Get perf binary data extension (optional).protected AbstractPerfAsmProfiler.PerfEvents
readEvents(double skipMs, double lenMs)
Read parsed events.-
Methods inherited from class org.openjdk.jmh.profile.AbstractPerfAsmProfiler
addJVMOptions, allowPrintErr, allowPrintOut, stripEventNames
-
-
-
-
Field Detail
-
MSG_UNABLE_START
private static final java.lang.String MSG_UNABLE_START
- See Also:
- Constant Field Values
-
MSG_UNABLE_STOP
private static final java.lang.String MSG_UNABLE_STOP
- See Also:
- Constant Field Values
-
xperfProviders
private final java.lang.String xperfProviders
-
symbolDir
private final java.lang.String symbolDir
-
path
private final java.lang.String path
-
pid
private volatile java.lang.String pid
PID.
-
optXperfDir
private joptsimple.OptionSpec<java.lang.String> optXperfDir
-
optXperfProviders
private joptsimple.OptionSpec<java.lang.String> optXperfProviders
-
optSymbolDir
private joptsimple.OptionSpec<java.lang.String> optSymbolDir
-
-
Constructor Detail
-
WinPerfAsmProfiler
public WinPerfAsmProfiler(java.lang.String initLine) throws ProfilerException
- Throws:
ProfilerException
-
-
Method Detail
-
addMyOptions
protected void addMyOptions(joptsimple.OptionParser parser)
- Specified by:
addMyOptions
in classAbstractPerfAsmProfiler
-
addJVMInvokeOptions
public java.util.Collection<java.lang.String> addJVMInvokeOptions(BenchmarkParams params)
Description copied from interface:ExternalProfiler
Prepend 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:ExternalProfiler
Run this code before starting the trial. This method will execute before starting the benchmark JVM.- Specified by:
beforeTrial
in interfaceExternalProfiler
- Overrides:
beforeTrial
in classAbstractPerfAsmProfiler
- Parameters:
params
- benchmark parameters used for current launch
-
afterTrial
public java.util.Collection<? extends Result> afterTrial(BenchmarkResult br, long pid, java.io.File stdOut, java.io.File stdErr)
Description copied from interface:ExternalProfiler
Run this code after the trial is done. This method will execute after benchmark JVM had stopped.- Specified by:
afterTrial
in interfaceExternalProfiler
- Overrides:
afterTrial
in 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 java.lang.String getDescription()
Description copied from interface:Profiler
Human-readable one-line description of the profiler.- Returns:
- description
-
parseEvents
protected void parseEvents()
Description copied from class:AbstractPerfAsmProfiler
Parse profiler events from binary to text form.- Specified by:
parseEvents
in classAbstractPerfAsmProfiler
-
readEvents
protected AbstractPerfAsmProfiler.PerfEvents readEvents(double skipMs, double lenMs)
Description copied from class:AbstractPerfAsmProfiler
Read parsed events.- Specified by:
readEvents
in classAbstractPerfAsmProfiler
- Parameters:
skipMs
- Milliseconds to skip.lenMs
- Milliseconds to capture after skip- Returns:
- Events.
-
perfBinaryExtension
protected java.lang.String perfBinaryExtension()
Description copied from class:AbstractPerfAsmProfiler
Get perf binary data extension (optional).- Specified by:
perfBinaryExtension
in classAbstractPerfAsmProfiler
- Returns:
- Extension.
-
-