Change summary
internal/tui/components/anim/anim.go | 6 +++---
internal/tui/components/anim/anim_test.go | 22 +++++++++++-----------
2 files changed, 14 insertions(+), 14 deletions(-)
Detailed changes
@@ -17,9 +17,9 @@ import (
)
const (
- charCyclingFPS = time.Second / 8 // Reduced from 22 to 8 FPS for better CPU efficiency
- colorCycleFPS = time.Second / 3 // Reduced from 5 to 3 FPS
- maxCyclingChars = 60 // Reduced from 120 to 60 characters
+ charCyclingFPS = time.Second / 8 // Reduced from 22 to 8 FPS for better CPU efficiency
+ colorCycleFPS = time.Second / 3 // Reduced from 5 to 3 FPS
+ maxCyclingChars = 60 // Reduced from 120 to 60 characters
)
var (
@@ -7,7 +7,7 @@ import (
func BenchmarkAnimationUpdate(b *testing.B) {
anim := New(30, "Loading test data")
-
+
b.ResetTimer()
for i := 0; i < b.N; i++ {
// Simulate character cycling update
@@ -17,12 +17,12 @@ func BenchmarkAnimationUpdate(b *testing.B) {
func BenchmarkAnimationView(b *testing.B) {
anim := New(30, "Loading test data")
-
+
// Initialize with some cycling
for i := 0; i < 10; i++ {
anim.Update(StepCharsMsg{id: anim.ID()})
}
-
+
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = anim.View()
@@ -31,7 +31,7 @@ func BenchmarkAnimationView(b *testing.B) {
func BenchmarkRandomRune(b *testing.B) {
c := cyclingChar{}
-
+
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = c.randomRune()
@@ -40,24 +40,24 @@ func BenchmarkRandomRune(b *testing.B) {
func TestAnimationPerformance(t *testing.T) {
anim := New(30, "Performance test")
-
+
start := time.Now()
iterations := 1000
-
+
// Simulate rapid updates
for i := 0; i < iterations; i++ {
anim.Update(StepCharsMsg{id: anim.ID()})
_ = anim.View()
}
-
+
duration := time.Since(start)
avgPerUpdate := duration / time.Duration(iterations)
-
+
// Should complete 1000 updates in reasonable time
if avgPerUpdate > time.Millisecond {
t.Errorf("Animation update too slow: %v per update (should be < 1ms)", avgPerUpdate)
}
-
- t.Logf("Animation performance: %v per update (%d updates in %v)",
+
+ t.Logf("Animation performance: %v per update (%d updates in %v)",
avgPerUpdate, iterations, duration)
-}
+}