I'm using the VMware Guest SDK library to figure out the CPU ready time of the virtual machine running my application.
According the VMware documentation, the method VMGuestLib_GetCpuStolenMs of the vmGuestLib provides this value:
The time (in ms) that the VM was runnable but not scheduled.
However, if I chart the CPU ready time for the same virtual machine in the vSphere client I get different values. For instance, whereas I get CPU ready times between 0 and 22ms in the vSphere Client for 20s intervals, I get stolen times of 550 to 650ms using the VMware Guest SDK library for (roughly) the same time spans.
My calculation of the CPU stolen time for the last 20s looks like this (pseudo code):
oldStolenMs = vmLib.getCpuStolenMs()
sleep_in_seconds(20)
newStolenMs = vmLib.getCpuStolenMs()
stolenMs = newStolenMs - oldStolenMs
// additionally I verify that the elapsed time of the VM is indeed 20s