Package org.eclipse.jetty.toolchain.perf
Class PlatformMonitor
java.lang.Object
org.eclipse.jetty.toolchain.perf.PlatformMonitor
- All Implemented Interfaces:
Runnable
Helper class that reports a number of information about the JVM and the OS,
useful to monitor the JVM during a benchmark.
Typical usage:
PlatformMonitor monitor = new PlatformMonitor();
Start start = monitor.start();
if (start != null)
{
// Monitoring started, print out
// initial platform information.
System.err.println(start);
// Perform benchmark
Stop stop = monitor.stop();
if (stop != null)
{
// Monitoring stopped, print out
// ending platform information.
System.err.println(stop);
}
}
PlatformMonitor supports multiple concurrent invocations to
start() and stop(), so that it can be used on a
server when multiple clients sends to the server a "start monitor"
message. Calls to start() and stop() must be paired
and a PlatformMonitor.Start object is returned for the first paired start()
call, and a PlatformMonitor.Stop object is returned for the last paired
stop() call.
GC activity is being polled, by default every 250 ms, see
setMemoryPollInterval(long).
If the benchmark triggers GC at a higher rate, the results reported
by this class may be inaccurate.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongvoidrun()voidsetMemoryPollInterval(long gcPollInterval)start()Starts monitoring the platform.stop()Stops the monitoring of the platform.
-
Constructor Details
-
PlatformMonitor
public PlatformMonitor()
-
-
Method Details
-
getMemoryPollInterval
public long getMemoryPollInterval() -
setMemoryPollInterval
public void setMemoryPollInterval(long gcPollInterval) -
run
public void run() -
start
Starts monitoring the platform.This method returns aPlatformMonitor.Startobject the first time it is invoked, or the first time it is invoked after pairedstop()calls. For example:PlatformMonitor monitor = new PlatformMonitor(); Start start = monitor.start(); // first start call, start != null start = monitor.start(); // second start call, start == null Stop stop = monitor.stop(); // first stop call, stop == null stop = monitor.stop(); // last stop call, stop != null start = monitor.start(); // first start call after paired stops, start != null stop = monitor.stop(); // paired stop call, stop != null
- Returns:
- a
PlatformMonitor.Startobject if the monitoring started, null for additional calls to this method not paired with astop()call. - See Also:
stop()
-
stop
Stops the monitoring of the platform.- Returns:
- a
PlatformMonitor.Stopobject if the monitoring stopped, null for calls to this method not paired with the firststart()call. - See Also:
start()
-