Integrated: 8335625: Update Javadoc for GetCpuLoad
Joakim Nordström
jnordstrom at openjdk.org
Tue Sep 10 13:52:15 UTC 2024
On Mon, 12 Aug 2024 12:33:04 GMT, Joakim Nordström <jnordstrom at openjdk.org> wrote:
> Can I get a review of this documentation update to clarify the usage of GetCpuLoad (and inherently deprecated GetSystemCpuLoad) and GetProcessCpuLoad.
>
> Calling either of these methods in quick succession can lead to unrepresentative results due to too few data points.
>
> This behavior is easy to reproduce on at least Linux (Windows implementation enforces a 500 ticks duration); when calling GetCpuLoad repeatedly CPU load values of either 0, 0.5, or 1 will be returned.
>
> double cpuLoad1 = getCpuLoad();
> double cpuLoad2 = getCpuLoad(); // not enough ticks has passed to give representative values
>
> Worth noting is that this holds true even if getSystemCpuLoad() is called.
>
> double cpuLoad1 = getCpuLoad();
> double cpuLoad2 = getSystemCpuLoad(); // not enough ticks has passed to give representative values, since getSystemCpuLoad effectively calls getCpuLoad.
This pull request has now been integrated.
Changeset: 64a79d89
Author: Joakim Nordström <jnordstrom at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/64a79d898637e9255e6c1133dd684e272d84b95c
Stats: 41 lines in 1 file changed: 28 ins; 0 del; 13 mod
8335625: Update Javadoc for GetCpuLoad
Reviewed-by: alanb, kevinw
-------------
PR: https://git.openjdk.org/jdk/pull/20546
More information about the serviceability-dev
mailing list