public static class CumulativeCpuUsageEmulatorPlugin.DefaultCpuUsageEmulator extends Object implements CumulativeCpuUsageEmulatorPlugin.CpuUsageEmulatorCore
Modifier and Type | Field and Description |
---|---|
protected double |
returnValue
This is to fool the JVM and make it think that we need the value
stored in the unit computation i.e
compute() . |
Constructor and Description |
---|
CumulativeCpuUsageEmulatorPlugin.DefaultCpuUsageEmulator()
Initialized the
CumulativeCpuUsageEmulatorPlugin.DefaultCpuUsageEmulator with default values. |
Modifier and Type | Method and Description |
---|---|
void |
calibrate(ResourceCalculatorPlugin monitor,
long totalCpuUsage)
This will calibrate the algorithm such that a single invocation of
compute() emulates roughly 1% of the total desired resource
usage value. |
void |
compute()
This will consume some desired level of CPU.
|
protected void |
performUnitComputation() |
protected double returnValue
compute()
. This will prevent
the JVM from optimizing the code.public CumulativeCpuUsageEmulatorPlugin.DefaultCpuUsageEmulator()
CumulativeCpuUsageEmulatorPlugin.DefaultCpuUsageEmulator
with default values.
Note that the CumulativeCpuUsageEmulatorPlugin.DefaultCpuUsageEmulator
should be calibrated
(see calibrate(ResourceCalculatorPlugin, long)
) when initialized
using this constructor.public void compute()
compute
in interface CumulativeCpuUsageEmulatorPlugin.CpuUsageEmulatorCore
protected void performUnitComputation()
public void calibrate(ResourceCalculatorPlugin monitor, long totalCpuUsage)
compute()
emulates roughly 1% of the total desired resource
usage value.calibrate
in interface CumulativeCpuUsageEmulatorPlugin.CpuUsageEmulatorCore
Copyright © 2013 Apache Software Foundation. All rights reserved.