Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

test(gameengine): add 60 Hz gate holding eight AIs at 2000 objects

Olcay Seygan7876ea57feb9
diff --git a/GeneralsMD/Code/BuildFingerprint.manifest b/GeneralsMD/Code/BuildFingerprint.manifest
index 45c05f86c..20d0e3957 100644
--- a/GeneralsMD/Code/BuildFingerprint.manifest
+++ b/GeneralsMD/Code/BuildFingerprint.manifest
@@ -294,6 +294,7 @@ Data/Scenarios/explreel.txt
Data/Scenarios/firelook.txt
Data/Scenarios/flatshells.txt
Data/Scenarios/fogleak.txt
+Data/Scenarios/gate60hz.txt
Data/Scenarios/geproto_alpine.txt
Data/Scenarios/geproto_fogedge.txt
Data/Scenarios/geproto_glow.txt
diff --git a/GeneralsMD/Code/Data/Scenarios/gate60hz.txt b/GeneralsMD/Code/Data/Scenarios/gate60hz.txt
new file mode 100644
index 000000000..d46c971eb
--- /dev/null
+++ b/GeneralsMD/Code/Data/Scenarios/gate60hz.txt
@@ -0,0 +1,34 @@
+# The crowd gate-60hz.ps1 measures: eight AIs on Twilight Flame held at 2000 objects from minute ten
+# on, the working target of 60 Hz however long a match runs. Left alone the same match peaks near 1560
+# with a mean of 1240, and money, -teams and a bigger map do not move that, because population caps
+# and the AI's spending stop it first. One unit a frame at most while the world is under the number,
+# the lines taking turns, every seat the same three kinds on its road to the centre of the map.
+#
+# .\gate-60hz.ps1 -Minutes 17 -Window 2
+#
+# The frames are 30 Hz, so 18000 is logic frame 36000.
+
+18000 topup 0 AmericaInfantryRanger 2000
+18000 topup 0 AmericaInfantryMissileDefender 2000
+18000 topup 0 AmericaTankCrusader 2000
+18000 topup 1 ChinaInfantryRedguard 2000
+18000 topup 1 ChinaInfantryTankHunter 2000
+18000 topup 1 ChinaTankBattleMaster 2000
+18000 topup 2 GLAInfantryRebel 2000
+18000 topup 2 GLAInfantryTunnelDefender 2000
+18000 topup 2 GLATankScorpion 2000
+18000 topup 3 AmericaInfantryRanger 2000
+18000 topup 3 AmericaInfantryMissileDefender 2000
+18000 topup 3 AmericaTankCrusader 2000
+18000 topup 4 ChinaInfantryRedguard 2000
+18000 topup 4 ChinaInfantryTankHunter 2000
+18000 topup 4 ChinaTankBattleMaster 2000
+18000 topup 5 GLAInfantryRebel 2000
+18000 topup 5 GLAInfantryTunnelDefender 2000
+18000 topup 5 GLATankScorpion 2000
+18000 topup 6 AmericaInfantryRanger 2000
+18000 topup 6 AmericaInfantryMissileDefender 2000
+18000 topup 6 AmericaTankCrusader 2000
+18000 topup 7 ChinaInfantryRedguard 2000
+18000 topup 7 ChinaInfantryTankHunter 2000
+18000 topup 7 ChinaTankBattleMaster 2000
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h
index 038a393c1..122317112 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h
@@ -97,7 +97,8 @@ enum ScenarioActionType
SCENARIO_ACTION_RANK, ///< rank <slot> <selector> veteran|elite|heroic|xp N|grade N; a level as the rank cheat sets it (a ladder's pin), N same-class kills of experience, or a ladder grade
SCENARIO_ACTION_GIVEMONEY, ///< givemoney <slot> <targetSlot> <amount>; the Tab screen's Send, as MSG_TRANSFER_MONEY onto the message stream
SCENARIO_ACTION_CLICKSTOP, ///< clickstop <slot> <selector>; the Stop key, the group idle MSG_DO_STOP gives (CMD_FROM_PLAYER)
- SCENARIO_ACTION_REACHPROOF ///< reachproof <slot> <selector> <targetSlot> <probe> [samples]; every matching defence's reach overlay against the logic, the probe stood on each sample point (ReachOverlay_prove)
+ SCENARIO_ACTION_REACHPROOF, ///< reachproof <slot> <selector> <targetSlot> <probe> [samples]; every matching defence's reach overlay against the logic, the probe stood on each sample point (ReachOverlay_prove)
+ SCENARIO_ACTION_TOPUP ///< topup <slot> <template> <objects>; from now on, while the world holds fewer objects than that, this line's turn makes one on the road from the seat's start to the map's centre and attack-moves it there
};
/// ScenarioAction::atStart when the position is plain numbers
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
index 94d310ca6..4c672826a 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
@@ -2103,16 +2103,16 @@ static void reportFrameTimeStats( void )
theFrameTimes.countOver( 16.7f ), over16,
theFrameTimes.countOver( 33.3f ), over33,
theFrameTimes.countOver( 25.0f )));
- // the same passes split for the logic thread plan: mean/p50/p99 of each part
- #define PASS_SPLIT(h) (h).meanMS(), (h).percentileMS( 0.50f ), (h).percentileMS( 0.99f )
- DEBUG_LOG(("HEADLESS PASSES TICK: %d | pass %.2f/%.2f/%.2f | sync %.2f/%.2f/%.2f | render %.2f/%.2f/%.2f | logic %.2f/%.2f/%.2f ms mean/p50/p99\n",
+ // the same passes split for the logic thread plan: mean/p50/p99/p99.9 of each part
+ #define PASS_SPLIT(h) (h).meanMS(), (h).percentileMS( 0.50f ), (h).percentileMS( 0.99f ), (h).percentileMS( 0.999f )
+ DEBUG_LOG(("HEADLESS PASSES TICK: %d | pass %.2f/%.2f/%.2f/%.2f | sync %.2f/%.2f/%.2f/%.2f | render %.2f/%.2f/%.2f/%.2f | logic %.2f/%.2f/%.2f/%.2f ms mean/p50/p99/p99.9\n",
theTickPass.count(), PASS_SPLIT( theTickPass ), PASS_SPLIT( theTickSync ),
PASS_SPLIT( theTickRender ), PASS_SPLIT( theTickLogic )));
- DEBUG_LOG(("HEADLESS PASSES NOTICK: %d | pass %.2f/%.2f/%.2f | sync %.2f/%.2f/%.2f | render %.2f/%.2f/%.2f ms mean/p50/p99\n",
+ DEBUG_LOG(("HEADLESS PASSES NOTICK: %d | pass %.2f/%.2f/%.2f/%.2f | sync %.2f/%.2f/%.2f/%.2f | render %.2f/%.2f/%.2f/%.2f ms mean/p50/p99/p99.9\n",
theRenderPass.count(), PASS_SPLIT( theRenderPass ), PASS_SPLIT( theRenderSync ),
PASS_SPLIT( theRenderRender )));
- DEBUG_LOG(("HEADLESS PASSES OVERLAPPED: %d | %.2f/%.2f/%.2f p99.9 %.2f ms mean/p50/p99, every pass with the tick beside the render\n",
- theOverlapped.count(), PASS_SPLIT( theOverlapped ), theOverlapped.percentileMS( 0.999f )));
+ DEBUG_LOG(("HEADLESS PASSES OVERLAPPED: %d | %.2f/%.2f/%.2f/%.2f ms mean/p50/p99/p99.9, every pass with the tick beside the render\n",
+ theOverlapped.count(), PASS_SPLIT( theOverlapped )));
#undef PASS_SPLIT
if (TheGlobalData)
{
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp
index 3c99a69c5..61e01a649 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp
@@ -256,6 +256,8 @@ static Bool parseActionType( const AsciiString &token, ScenarioActionType *actio
*action = SCENARIO_ACTION_RANK;
else if (token == "reachproof")
*action = SCENARIO_ACTION_REACHPROOF;
+ else if (token == "topup")
+ *action = SCENARIO_ACTION_TOPUP;
else
return FALSE;
@@ -363,6 +365,7 @@ static Int tokensNeededFor( ScenarioActionType action )
case SCENARIO_ACTION_TALLY: return SCENARIO_TOKENS_STOP;
case SCENARIO_ACTION_PURCHASE: return SCENARIO_TOKENS_STOP;
case SCENARIO_ACTION_ARRIVE: return SCENARIO_TOKENS_ARRIVE;
+ case SCENARIO_ACTION_TOPUP: return SCENARIO_TOKENS_MOVE;
}
return SCENARIO_TOKENS_STOP;
}
@@ -409,6 +412,11 @@ ScenarioParseResult ScenarioDrill_parseLine( const char *line, ScenarioAction *a
switch (actionType)
{
+ case SCENARIO_ACTION_TOPUP:
+ if (!parseWholeNumber( tokens[ 4 ], &action->count ) || action->count < 1)
+ return SCENARIO_PARSE_BAD_COUNT;
+ break;
+
case SCENARIO_ACTION_SPAWN:
case SCENARIO_ACTION_PARTICLES:
{
@@ -566,6 +574,7 @@ const char *ScenarioDrill_parseResultName( ScenarioParseResult result )
// ------------------------------------------------------------------------------------------------
static std::vector<ScenarioAction> theScenarioActions;
+static std::vector<ScenarioAction> theScenarioTopups;
static Int theScenarioCursor = 0;
static Bool theScenarioLoaded = FALSE;
static Int theScenarioActionsRun = 0;
@@ -637,6 +646,7 @@ static void resetScenario( void )
theScenarioArrivals.clear();
theScenarioResponses.clear();
theScenarioActions.clear();
+ theScenarioTopups.clear();
theScenarioCursor = 0;
theScenarioLoaded = FALSE;
theScenarioActionsRun = 0;
@@ -855,11 +865,11 @@ static Object *findNearestCivilian( const AsciiString &selector, const Coord3D *
pathfinder puts every destination to: a tank set on a cliff or in the sea is taken away again
rather than left to drive out. Aircraft are not asked: anything on a JetAIUpdate, the Comanche
included, is made on its ground-only taxiing set, which would refuse it on every cliff. */
-static Bool spawnOne( const ScenarioAction &action, const ThingTemplate *tmpl, Team *team, const Coord3D *pos )
+static Object *spawnOne( const ScenarioAction &action, const ThingTemplate *tmpl, Team *team, const Coord3D *pos )
{
Object *obj = TheThingFactory->newObject( tmpl, team );
if (obj == NULL)
- return FALSE;
+ return NULL;
obj->setOrientation( 0 );
obj->setPosition( pos );
@@ -877,7 +887,7 @@ static Bool spawnOne( const ScenarioAction &action, const ThingTemplate *tmpl, T
action.frame, action.slot, action.selector.str(), pos->x, pos->y, type,
cell != NULL ? cellNames[type] : "OFF_MAP"));
TheGameLogic->destroyObject( obj );
- return FALSE;
+ return NULL;
}
for( BehaviorModule **m = obj->getBehaviorModules(); *m; ++m )
@@ -893,7 +903,58 @@ static Bool spawnOne( const ScenarioAction &action, const ThingTemplate *tmpl, T
team->setActive();
TheAI->pathfinder()->addObjectToPathfindMap( obj );
- return TRUE;
+ return obj;
+}
+
+static Coord3D mapCentre( void )
+{
+ Region3D extent;
+ TheTerrainLogic->getExtent( &extent );
+ Coord3D centre;
+ centre.x = ( extent.lo.x + extent.hi.x ) * 0.5f;
+ centre.y = ( extent.lo.y + extent.hi.y ) * 0.5f;
+ centre.z = TheTerrainLogic->getGroundHeight( centre.x, centre.y );
+ return centre;
+}
+
+/** The frame-time gate's crowd. Money, the team count and a bigger map all stop near 1500 objects,
+ because population caps and the AI's spending stop there, so this is what gets a match to its
+ target: one unit a frame at most, so the top-up is no burst of its own in the tail it measures,
+ the file's lines taking turns on the frame number so every seat gets its share. The count and
+ the frame are logic state, so the same seed draws the same crowd. It starts on the road from the
+ seat's start towards the centre, on the first clear ground from 40% of the way out so it clears
+ the base, and the small offset keeps a jam of them from standing on one point. */
+static void runTopups( UnsignedInt now )
+{
+ if (theScenarioTopups.empty())
+ return;
+ const ScenarioAction &line = theScenarioTopups[ now % theScenarioTopups.size() ];
+ if (TheGameLogic->getObjectCount() >= (UnsignedInt)line.count)
+ return;
+
+ AsciiString waypointName;
+ waypointName.format( "Player_%d_Start", line.slot + 1 );
+ const Waypoint *start = TheTerrainLogic->getWaypointByName( waypointName );
+ if (start == NULL)
+ return;
+
+ const Coord3D centre = mapCentre();
+ Coord3D pos;
+ for( Real along = 0.4f; along < 1.0f; along += 0.1f )
+ {
+ pos.x = start->getLocation()->x + ( centre.x - start->getLocation()->x ) * along + (Real)( now % 7 ) * 30.0f - 90.0f;
+ pos.y = start->getLocation()->y + ( centre.y - start->getLocation()->y ) * along + (Real)( now % 11 ) * 30.0f - 150.0f;
+ pos.z = TheTerrainLogic->getGroundHeight( pos.x, pos.y );
+ const PathfindCell *cell = TheAI->pathfinder()->getCell( LAYER_GROUND, &pos );
+ if (cell != NULL && cell->getType() == PathfindCell::CELL_CLEAR)
+ break;
+ }
+
+ Object *obj = spawnOne( line, TheThingFactory->findTemplate( line.selector, FALSE ), findPlayerForSlot( line.slot )->getDefaultTeam(), &pos );
+ if (obj == NULL)
+ return;
+ ++theScenarioUnitsSpawned;
+ obj->getAI()->aiAttackMoveToPosition( &centre, NO_MAX_SHOTS_LIMIT, CMD_FROM_AI );
}
static Bool executeSpawn( const ScenarioAction &action, Player *player, const Coord3D &centre )
@@ -1937,6 +1998,7 @@ static Bool executeOrder( const ScenarioAction &action, Player *player, const Co
case SCENARIO_ACTION_TALLY:
case SCENARIO_ACTION_RESPOND:
case SCENARIO_ACTION_REACHPROOF:
+ case SCENARIO_ACTION_TOPUP:
ordered = FALSE; // handled before the group is built
break;
}
@@ -2060,6 +2122,20 @@ Bool ScenarioDrill_execute( const ScenarioAction &action )
return FALSE;
}
+ if (action.action == SCENARIO_ACTION_TOPUP)
+ {
+ if (TheThingFactory->findTemplate( action.selector, FALSE ) == NULL)
+ {
+ DEBUG_LOG(("SCENARIO: frame %d topup: no template named '%s'\n", action.frame, action.selector.str()));
+ return FALSE;
+ }
+ theScenarioTopups.push_back( action );
+ const Coord3D centre = mapCentre();
+ DEBUG_LOG(("SCENARIO: frame %d topup slot %d '%s' to %d objects, road to (%.0f,%.0f)\n", action.frame, action.slot,
+ action.selector.str(), action.count, centre.x, centre.y));
+ return TRUE;
+ }
+
Coord3D position;
if (!resolveScenarioPosition( action, &position ))
return FALSE;
@@ -2131,7 +2207,10 @@ void ScenarioDrill_tick( void )
if (!theScenarioLoaded)
loadScenario();
- updateStatues( now );
+ // the gate's crowd is there to measure the frame, and the statue count's walk of every unit would be in it
+ if (theScenarioTopups.empty())
+ updateStatues( now );
+ runTopups( now );
// a scenario file counts 30 Hz frames, so the files written before 60 Hz logic play at the same seconds
while (theScenarioCursor < (Int)theScenarioActions.size()
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index 5b020e8d7..35cb2b249 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -19125,6 +19125,15 @@ TEST(scenario_parses_a_particles_line)
// the same count and position rules as spawn, because it shares spawn's parse
CHECK_EQ( (Int)ScenarioDrill_parseLine( "30 particles 0 X 0 760 850", &action ), (Int)SCENARIO_PARSE_BAD_COUNT );
CHECK_EQ( (Int)ScenarioDrill_parseLine( "30 particles 0 X 5 760", &action ), (Int)SCENARIO_PARSE_MISSING_ARGS );
+
+ // the gate's top-up: seat, template and the object count it holds the world at
+ CHECK_EQ( (Int)ScenarioDrill_parseLine( "18000 topup 3 GLATankScorpion 2000", &action ), (Int)SCENARIO_PARSE_OK );
+ CHECK_EQ( (Int)action.action, (Int)SCENARIO_ACTION_TOPUP );
+ CHECK_EQ( action.slot, 3 );
+ CHECK( action.selector == "GLATankScorpion" );
+ CHECK_EQ( action.count, 2000 );
+ CHECK_EQ( (Int)ScenarioDrill_parseLine( "18000 topup 3 GLATankScorpion", &action ), (Int)SCENARIO_PARSE_MISSING_ARGS );
+ CHECK_EQ( (Int)ScenarioDrill_parseLine( "18000 topup 3 GLATankScorpion none", &action ), (Int)SCENARIO_PARSE_BAD_COUNT );
}
// A queued order that is not an order would never end a list when given without shift, and an order
diff --git a/gate-60hz.ps1 b/gate-60hz.ps1
new file mode 100644
index 000000000..17cea48fe
--- /dev/null
+++ b/gate-60hz.ps1
@@ -0,0 +1,142 @@
+<#
+.SYNOPSIS
+ The 60 Hz gate: eight AIs, 2000 objects, a drawn match, and a nonzero exit when p99.9 passes 16.7 ms.
+
+.DESCRIPTION
+ The bar is every frame under 16.7 ms however long a match runs, on Twilight Flame with eight Hard
+ AIs, so a mean says nothing here and the number judged is p99.9, logic and picture each on its own
+ line. Scenarios/gate60hz.txt holds the match at 2000 objects from minute ten on, which is the most
+ it is built for; the plain match stops near 1560.
+
+ The window draws at 1080p with 4x MSAA and the logic on its own thread (-logicthread 1), so the
+ picture's tail and the logic's come apart: a tick pass that waits on logic is the logic's
+ fault and shows in LOGICTIME, the render's own share in the PASSES lines. The whole thing is one
+ seed, so the same exe draws the same crowd and a -Window run is a slice of the same match the hour
+ plays: two exes are compared gate to gate, never against a plain match (-scenario fixes the start
+ positions, so its CRC is its own).
+
+ Failing is a result: this reports it and exits 1. Exit 2 is a run that gave no numbers (crashed,
+ killed, or stopped short), and a run that never reached the object count is a failure too, because
+ a green gate at 1200 objects would say nothing about 2000.
+
+.EXAMPLE
+ .\gate-60hz.ps1
+ The hour: 216000 logic frames, all of them drawn. A real hour once it holds 60 Hz, about two
+ today, since the run falls behind the clock and never drops a tick.
+
+.EXAMPLE
+ .\gate-60hz.ps1 -Minutes 17 -Window 2
+ Undrawn up to minute 15, then two drawn minutes. About thirteen minutes of wall clock.
+#>
+param(
+ # game minutes the match runs, 60 logic frames a second
+ [int] $Minutes = 60,
+ # draw only the last this many of them and reach the rest undrawn at full speed; 0 draws all of them
+ [int] $Window = 0,
+ # where the game is
+ [string] $RunDir = "$PSScriptRoot\GeneralsMD\Run",
+ [string] $Exe = "generals.exe",
+ # switches to add to the run
+ [string[]] $ExtraArgs = @(),
+ # the game's user data folder (ZH_USER_DATA_DIR). Empty: the player's own, in Documents
+ [string] $UserDataDir = "",
+ # minutes of wall clock before a run is killed and counted as no result
+ [int] $TimeoutMinutes = 180
+)
+
+$ErrorActionPreference = "Stop"
+$env:ZH_UNATTENDED = "1" # no box may wait on a person (EarlyCommandLine.h)
+
+$BudgetMS = 16.7
+$ObjectTarget = 2000 # Scenarios/gate60hz.txt
+$HistogramTopMS = 64 # the log's frame time histogram: past this a percentile reads as the worst frame
+
+$exePath = Join-Path $RunDir $Exe
+if (-not (Test-Path $exePath)) { throw "no $Exe in $RunDir" }
+if ($UserDataDir -ne "") {
+ New-Item -ItemType Directory -Force $UserDataDir | Out-Null
+ $env:ZH_USER_DATA_DIR = (Resolve-Path $UserDataDir).Path
+} else {
+ Remove-Item Env:\ZH_USER_DATA_DIR -ErrorAction SilentlyContinue
+}
+
+$lastFrame = $Minutes * 60 * 60
+$prefix = "gate60hz_"
+$log = Join-Path $RunDir "${prefix}DebugLogFile.txt"
+if (Test-Path $log) { Remove-Item $log -Force }
+
+# -noFPSLimit: a windowed device honours vsync and a run paced by the monitor measures the monitor.
+# No -slowframe: a bar low enough to help writes and flushes a line on every frame over it, and those
+# frames are the ones being measured. The camera sits where the road from every seat ends.
+$runArgs = @("-win", "-borderless", "-xres", "1920", "-yres", "1080", "-msaa", "4", "-particlecap", "2500", "-nochroma",
+ "-noFPSLimit", "-quickstart", "-noshellmap", "-observer", "-multiInstance",
+ "-map", '"Maps\Twilight Flame\Twilight Flame.map"', "-autoskirmish", "8", "-teams", "2", "-aidiff", "hard", "-seed", "3",
+ "-logicthread", "1", "-scenario", "gate60hz", "-camera", "2430", "2345",
+ "-maxframes", $lastFrame, "-logPrefix", $prefix) + $ExtraArgs
+if ($Window -gt 0) { $runArgs += @("-jumpToFrame", (($Minutes - $Window) * 60 * 60)) }
+
+$proc = Start-Process -FilePath $exePath -ArgumentList $runArgs -WorkingDirectory $RunDir -PassThru
+$null = $proc.Handle # kept, so ExitCode is still there after the exit
+try {
+ $proc.PriorityClass = 'AboveNormal'
+ if (-not $proc.WaitForExit($TimeoutMinutes * 60 * 1000)) {
+ Write-Host ("KILLED: past {0} min" -f $TimeoutMinutes)
+ exit 2
+ }
+} finally {
+ if (-not $proc.HasExited) { $proc.Kill(); $proc.WaitForExit() }
+}
+
+function Get-LogMatch([string] $pattern)
+{
+ if (-not (Test-Path $log)) { return $null }
+ $hit = Select-String -Path $log -Pattern $pattern | Select-Object -Last 1
+ if ($null -eq $hit) { return $null }
+ return $hit.Matches[0].Groups
+}
+
+$time = 'mean ([\d.]+) p50 [\d.]+ p95 [\d.]+ p99 ([\d.]+) p99\.9 ([\d.]+) worst ([\d.]+) ms \(frame (\d+)\)'
+$frame = Get-LogMatch "HEADLESS FRAMETIME: (\d+) frames \| $time \| over 16\.7ms (\d+) \(([\d.]+)%\)"
+$logic = Get-LogMatch "HEADLESS LOGICTIME: (\d+) ticks \| $time"
+$objects = Get-LogMatch 'HEADLESS OBJECTS: peak (\d+) \(frame (\d+)\) \| mean (\d+)'
+$crc = Get-LogMatch 'HEADLESS CRC: (0x[0-9A-F]+) at frame (\d+)'
+$scenario = Get-LogMatch 'HEADLESS SCENARIO: (.+)$'
+$part = '([\d.]+)/([\d.]+)/([\d.]+)/([\d.]+)'
+$tick = Get-LogMatch "HEADLESS PASSES TICK: (\d+) \| pass $part \| sync $part \| render $part \| logic $part"
+$noTick = Get-LogMatch "HEADLESS PASSES NOTICK: (\d+) \| pass $part \| sync $part \| render $part"
+
+if ($null -eq $frame -or $null -eq $logic -or $null -eq $objects -or $null -eq $crc -or [int] $crc[2].Value -ne $lastFrame) {
+ Write-Host ("NO RESULT: exit {0}, the log {1} holds no full run to {2} frames" -f $proc.ExitCode, $log, $lastFrame)
+ exit 2
+}
+
+$frameTail = [double] $frame[4].Value
+$logicTail = [double] $logic[4].Value
+$objectPeak = [int] $objects[1].Value
+
+Write-Host ("frame p99.9 {0} ms | mean {1} p99 {2} worst {3} (frame {4}) | {5} of {6} over 16.7 ms ({7}%)" -f
+ $frame[4].Value, $frame[2].Value, $frame[3].Value, $frame[5].Value, $frame[6].Value,
+ $frame[7].Value, $frame[1].Value, $frame[8].Value)
+if ($frameTail -gt $HistogramTopMS) {
+ Write-Host (" p99.9 is past the histogram's {0} ms, so it reads as the worst frame; the mean is the number to read" -f $HistogramTopMS)
+}
+Write-Host ("logic p99.9 {0} ms | mean {1} p99 {2} worst {3} (frame {4})" -f
+ $logic[4].Value, $logic[2].Value, $logic[3].Value, $logic[5].Value, $logic[6].Value)
+if ($null -ne $tick -and $null -ne $noTick) {
+ Write-Host ("render p99.9 {0} ms on {1} passes with a tick, sync {2}; {3} ms on {4} passes without, sync {5}" -f
+ $tick[13].Value, $tick[1].Value, $tick[9].Value, $noTick[13].Value, $noTick[1].Value, $noTick[9].Value)
+}
+Write-Host ("objects peak {0} (frame {1}) mean {2}, target {3}" -f $objectPeak, $objects[2].Value, $objects[3].Value, $ObjectTarget)
+Write-Host ("crc {0} at frame {1}" -f $crc[1].Value, $crc[2].Value)
+if ($null -ne $scenario) { Write-Host ("scenario {0}" -f $scenario[1].Value) }
+
+$failed = @()
+if ($frameTail -gt $BudgetMS) { $failed += "frame p99.9" }
+if ($logicTail -gt $BudgetMS) { $failed += "logic p99.9" }
+if ($objectPeak -lt $ObjectTarget) { $failed += "object count" }
+if ($failed.Count -gt 0) {
+ Write-Host ("FAIL: {0}" -f ($failed -join ", "))
+ exit 1
+}
+Write-Host "PASS"
+exit 0