diff options
| author | Somhairle H. Marisol <[email protected]> | 2026-09-22 04:12:45 +0800 |
|---|---|---|
| committer | Somhairle H. Marisol <[email protected]> | 2026-09-22 04:12:45 +0800 |
| commit | b7b3e799a7956010a2e93e52f5d21870c820e68a (patch) | |
| tree | f0f41f2084aa8f67b8ecb4e25c99bd870321cb8c /src/LivingVillage.Desktop | |
| parent | 5a36c762d47ca8df43eff30d582bed264dcf9b77 (diff) | |
| download | living-village-b7b3e799a7956010a2e93e52f5d21870c820e68a.tar.gz | |
feat(perf): LV_PERF_SOAK_SECONDS 让 64x48/sample 世界也能长时帧率采样(P22)
- sample 脚本跑完一轮后若未到 soak 秒数则回到开头继续,用于与 256x192
巡游做同口径的解锁帧率对比;默认 0 行为不变。
Diffstat (limited to 'src/LivingVillage.Desktop')
| -rw-r--r-- | src/LivingVillage.Desktop/Game.fs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/LivingVillage.Desktop/Game.fs b/src/LivingVillage.Desktop/Game.fs index 28c86db..4305cb6 100644 --- a/src/LivingVillage.Desktop/Game.fs +++ b/src/LivingVillage.Desktop/Game.fs @@ -209,6 +209,16 @@ type LivingVillageGame() as this = let mutable fpsSamples: float list = [] let mutable fpsFrames = 0 let mutable fpsSeconds = 0.0 + // P22:让 sample/legacy 世界也能长时间采样帧率(>0 时跑完一轮脚本后回到开头继续)。 + let perfSoakSeconds = + match Environment.GetEnvironmentVariable("LV_PERF_SOAK_SECONDS") with + | null | "" -> 0.0 + | v -> + match Double.TryParse(v, Globalization.NumberStyles.Float, Globalization.CultureInfo.InvariantCulture) with + | true, seconds when seconds > 0.0 -> seconds + | _ -> 0.0 + let perfSoakWatch = System.Diagnostics.Stopwatch() + let mutable perfSoakStarted = false let mutable prevKb = Unchecked.defaultof<KeyboardState> let mutable relationView = false let mutable relationSnapshot: float32[,] option = None @@ -419,6 +429,9 @@ type LivingVillageGame() as this = | None -> () member private this.RunSampleMode () = + if perfSoakSeconds > 0.0 && not perfSoakStarted then + perfSoakStarted <- true + perfSoakWatch.Start() let stageBefore = sampleState.Stage let positionBefore = world.Avatar.Pos let nextWorld, nextView, nextState = SampleScript.runFrame world m5View sampleState @@ -432,8 +445,11 @@ type LivingVillageGame() as this = if nextState.Stage <> stageBefore then printfn $"sample stage={nextState.Stage} tick={nextWorld.Tick} pos=({nextWorld.Avatar.Pos.X:F0},{nextWorld.Avatar.Pos.Y:F0})" if nextState.Stage = SampleScript.SampleComplete then - printfn (if nextState.TimedOut then "sample result=timeout" else "sample result=ok") - this.Exit() + if perfSoakSeconds > 0.0 && perfSoakWatch.Elapsed.TotalSeconds < perfSoakSeconds then + sampleState <- SampleScript.initial + else + printfn (if nextState.TimedOut then "sample result=timeout" else "sample result=ok") + this.Exit() /// P16-FIX:菜单截图模式。停在开始界面,按确定性帧表向下切到「读档」,帧表见 MenuShotScript。 member private this.RunMenuShot () = |
