There is an open issue at the VirtualBox Bug Tracker. They link to a blog post stating why you shouldn't use gettimeofday() to measure the passage of time:
The most portable way to measure time
correctly seems to be
clock_gettime(CLOCK_MONOTONIC, ...)