First, (while (u> (GetTime) -1024)) prepares for foreseen circumstances. I'm not entirely sure what those are, but there's Funny Risks to avoid.
Second, Fred is set up. Fred serves to give the engine some work for each frame, even though Fred is entirely black on a black background. Between the engine and the framework, they have to animate Fred slowly walking from one point to another. Without Fred, each tick would be over near instantly.
Finally, the machine speed counter is reset.
In the speed test's doit, the speed counter is incremented. After the first time this happens, a timer is set to expire in another 60 ticks, or one second (GetTime plus 60). That's the "done time".
Eventually, after doit has ran a couple times and the machine speed counter has increased accordingly, GetTime's return value will equal the done time, so we know one second has passed. When that happens, the test is stopped.
If the machine speed (number of times doit has ran in one second) is under 24, the "how fast" rating (gSeconds in manual decomp) is set to 0 (low). Under 44, it's 1, "medium". Under 80, it's 2, "high". Anything higher than that, it's 3. The "default how fast" global is set to match. QFG2's detail menu will show "low", "medium", or "high" options, with whichever matching the default replaced with "optimal". If I read this correctly, speeds over 80 have it drop to "high", since there's no "max" option.
Just for fun: LSL3's infamous exercise machines want (machineSpeed / 5) + 5 reps each. Except if you have debug mode enabled "to save Carlos' finger for other things", then it's just five reps each. So on a system that manages to run a hundred cycles of speed test in one second, you need 25 reps, four times. A thousand, because you're running DOS games from the late 80s on a Pentium III? 205 reps, four times. 820 in total. No wonder we invented MoSlo and such.
But to properly answer the question: in the ScummVM debugger, try vm_vars g 105 to see the value of gMachineSpeed, add a third parameter to change it. 113 is gHowFast and 183 is gDftHowFast. In my case both are 3 on startup and the machine speed is a whopping 255. If you have a copy of the QFG2 demo you can use its interpreter instead of the full version's to access the original in-game debugger and use the g command to inspect and edit globals, with the same numbers.