• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mlange-42 / arche-model / 6698858792

30 Oct 2023 09:19PM CUT coverage: 98.208% (+0.8%) from 97.455%
6698858792

push

github

web-flow
Fix full CPU load when paused (#47)

As reported in mlange-42/arche#304, systems spin at maximum speed when paused.

This PR fixes the issue by calculating the theoretical next update time even when paused (assuming 30 TPS). Also, UI system update logic needs to be performed even when there are no UI systems.

Fixes mlange-42/arche#304

Changes:

* prevent paused spinning by still calculating next update
* add a test for pausing the model/Systems
* limit FPS/TPS when paused
* execute UI system update logic also when there are no UI systems
* update changelog

30 of 30 new or added lines in 1 file covered. (100.0%)

548 of 558 relevant lines covered (98.21%)

124.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/model/util.go
1
package model
2

3
import "time"
4

5
// nextTime calculates the next intended update.
6
func nextTime(last time.Time, fps float64) time.Time {
215✔
7
        if fps <= 0 {
216✔
8
                return last
1✔
9
        }
1✔
10
        dt := time.Second / time.Duration(fps)
214✔
11
        now := time.Now()
214✔
12
        if now.After(last.Add(200 * time.Millisecond)) {
240✔
13
                return now.Add(-10 * time.Millisecond)
26✔
14
        }
26✔
15
        return last.Add(dt)
188✔
16
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc