Skip to content

Show the current TPS if it is slower than the target. #2062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/swarm-tui/Swarm/TUI/View.hs
Original file line number Diff line number Diff line change
Expand Up @@ -591,24 +591,39 @@ drawTPS :: AppState -> Widget Name
drawTPS s = hBox (tpsInfo : rateInfo)
where
tpsInfo
| l >= 0 = hBox [str (show n), txt " ", txt (number n "tick"), txt " / s"]
| l >= 0 = hBox [str (show n), txt " ", tpsIndicator s, txt (number n "tick"), txt " / s"]
-- | l >= 0 = hBox [str (show n), txt " ", txt (number n "tick"), txt " / s"]
| otherwise = hBox [txt "1 tick / ", str (show n), txt " s"]

rateInfo
| s ^. uiState . uiGameplay . uiTiming . uiShowFPS =
[ txt " ("
, let tpf = s ^. uiState . uiGameplay . uiTiming . uiTPF
in (if tpf >= fromIntegral ticksPerFrameCap then withAttr redAttr else id)
, (if tpf >= fromIntegral ticksPerFrameCap then withAttr redAttr else id)
(str (printf "%0.1f" tpf))
, txt " tpf, "
, str (printf "%0.1f" (s ^. uiState . uiGameplay . uiTiming . uiFPS))
, txt " fps)"
]
| otherwise = []

tpf = s ^. uiState . uiGameplay . uiTiming . uiTPF
l = s ^. uiState . uiGameplay . uiTiming . lgTicksPerSecond
n = 2 ^ abs l

tpsIndicator :: AppState -> Widget Name
tpsIndicator s
= hBox [txt "(", str $ show tps, txt ") "]
-- = str (show $ round tps )

-- | (tps / target) < 0.9 = str (show $ round tps )
-- | otherwise = emptyWidget
where
tpf = s ^. uiState . uiGameplay . uiTiming . uiTPF
fps = s ^. uiState . uiGameplay . uiTiming . uiFPS
tps = tpf * fps
-- l = s ^. uiState . uiGameplay . uiTiming . lgTicksPerSecond
-- target = 2 ^^ l

-- | The height of the REPL box. Perhaps in the future this should be
-- configurable.
replHeight :: Int
Expand Down