mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 21:35:59 +00:00
fix(hud): FPS and clocks read right after sleep and wake (#2552)
* fix(hud): frame times follow the paused session's clock shift * fix(hud): core clocks show their average over each sample
This commit is contained in:
1 parent
d63193393d
commit
827ab2d485
7 files changed
+120
-22
No files matched your search
@@ -0,0 +1,26 @@
|
||||
package com.droiddeck.launcher.hud
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class CoreClockAverageTest {
|
||||
private val freqs = longArrayOf(902_400L, 1_459_200L, 2_803_200L)
|
||||
|
||||
@Test fun aCoreShowsTheClockItRanAtThroughTheSample() {
|
||||
val before = arrayOf(freqs, longArrayOf(100L, 50L, 10L))
|
||||
val after = arrayOf(freqs, longArrayOf(125L, 50L, 35L))
|
||||
assertEquals(1_852_800L, HudMetrics.averageKhz(before, after))
|
||||
}
|
||||
|
||||
@Test fun theFirstSampleOrAChangedTableFallsBack() {
|
||||
val after = arrayOf(freqs, longArrayOf(1L, 2L, 3L))
|
||||
assertEquals(-1L, HudMetrics.averageKhz(null, after))
|
||||
assertEquals(-1L, HudMetrics.averageKhz(arrayOf(longArrayOf(1L), longArrayOf(0L)), after))
|
||||
assertEquals(-1L, HudMetrics.averageKhz(after, after))
|
||||
}
|
||||
|
||||
@Test fun theCpuClockIsTheFastestCore() {
|
||||
assertEquals(2_803, HudMetrics.fastestCoreMhz(intArrayOf(902, 2_803, 1_459)))
|
||||
assertEquals(null, HudMetrics.fastestCoreMhz(intArrayOf(0, 0)))
|
||||
}
|
||||
}
|
||||
@@ -81,6 +81,21 @@ class FrameStatsTest {
|
||||
assertEquals(0, stats.slowFrames(now, 60_000_000_000L))
|
||||
}
|
||||
|
||||
@Test fun guestFrameTimesMoveByThePausedSessionsClockShift() {
|
||||
val control = java.io.File.createTempFile("bl-clock", null)
|
||||
try {
|
||||
control.writeBytes(java.nio.ByteBuffer.allocate(8).order(java.nio.ByteOrder.LITTLE_ENDIAN).putLong(62_283_930_706L).array())
|
||||
val feed = GameFrameFeed(java.io.File("/nonexistent/droiddeck-hud/frames"), clockControl = control)
|
||||
assertEquals(62_283_930_706L, feed.guestClockShift(1_000_000_000L, 1_000_000_000L))
|
||||
control.writeBytes(java.nio.ByteBuffer.allocate(8).order(java.nio.ByteOrder.LITTLE_ENDIAN).putLong(70_000_000_000L).array())
|
||||
assertEquals(62_283_930_706L, feed.guestClockShift(1_050_000_000L, 1_000_000_000L))
|
||||
assertEquals(70_000_000_000L, feed.guestClockShift(1_200_000_000L, 100_000_000L))
|
||||
assertEquals(0L, GameFrameFeed(java.io.File("/nonexistent/droiddeck-hud/frames")).guestClockShift(0L, 0L))
|
||||
} finally {
|
||||
control.delete()
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun compositorFramesDoNotCountAsLiveGamescopeFrames() {
|
||||
val feed = GameFrameFeed(java.io.File("/nonexistent/droiddeck-hud/frames"))
|
||||
var now = 1_000_000_000L
|
||||
|
||||
Reference in new issue
Block a user