3

When I run this loop in MSYS2's Bash shell

function test() {
    bcdedit | grep hypervisorlaunchtype
    printf "Press ENTER to begin..." 1>&2
    read
    # warm-up
    for ((i=0; i<"$1"; i++)); do $(:); done

    # actual iterations
    local tstart="$(date "+%s%3N")"
    iterations=0
    local i
    for ((i=2; i<"$1"; i++)); do $(:); done
    local tend="$(date "+%s%3N")"  # 2 extra spawns here
    printf "%s ms/spawn" $((("$tend" - "$tstart") / "$i")) 1>&2
    read
}
test 300

I get around 23 ms/spawn if hypervisorlaunchtype is off, but around 4 ms/spawn if it is auto.

Here are GIFs comparing the two with equal iterations: Hyper-V off vs. Hyper-V auto.
(Note that the CPU time statistics are not staying at zero because of being broken -- they're staying at zero because they are actually too small. If you leave the program running long enough, they will increase.)

What causes this discrepancy?

user541686
  • 23,629

0 Answers0