on main help sign in
fix: anim fmt files
69b649dRaphael Amorim
internal/tui/components/anim/anim.go+3−3
@@ -17,9 +17,9 @@ import (
17)
17)
18
18
19const (
19const (
20− charCyclingFPS = time.Second / 8 // Reduced from 22 to 8 FPS for better CPU efficiency
20+ charCyclingFPS = time.Second / 8 // Reduced from 22 to 8 FPS for better CPU efficiency
21− colorCycleFPS = time.Second / 3 // Reduced from 5 to 3 FPS
21+ colorCycleFPS = time.Second / 3 // Reduced from 5 to 3 FPS
22− maxCyclingChars = 60 // Reduced from 120 to 60 characters
22+ maxCyclingChars = 60 // Reduced from 120 to 60 characters
23)
23)
24
24
25var (
25var (
internal/tui/components/anim/anim_test.go+11−11
@@ -7,7 +7,7 @@ import (
7
7
8func BenchmarkAnimationUpdate(b *testing.B) {
8func BenchmarkAnimationUpdate(b *testing.B) {
9 anim := New(30, "Loading test data")
9 anim := New(30, "Loading test data")
10−
10+
11 b.ResetTimer()
11 b.ResetTimer()
12 for i := 0; i < b.N; i++ {
12 for i := 0; i < b.N; i++ {
13 // Simulate character cycling update
13 // Simulate character cycling update
@@ -17,12 +17,12 @@ func BenchmarkAnimationUpdate(b *testing.B) {
17
17
18func BenchmarkAnimationView(b *testing.B) {
18func BenchmarkAnimationView(b *testing.B) {
19 anim := New(30, "Loading test data")
19 anim := New(30, "Loading test data")
20−
20+
21 // Initialize with some cycling
21 // Initialize with some cycling
22 for i := 0; i < 10; i++ {
22 for i := 0; i < 10; i++ {
23 anim.Update(StepCharsMsg{id: anim.ID()})
23 anim.Update(StepCharsMsg{id: anim.ID()})
24 }
24 }
25−
25+
26 b.ResetTimer()
26 b.ResetTimer()
27 for i := 0; i < b.N; i++ {
27 for i := 0; i < b.N; i++ {
28 _ = anim.View()
28 _ = anim.View()
@@ -31,7 +31,7 @@ func BenchmarkAnimationView(b *testing.B) {
31
31
32func BenchmarkRandomRune(b *testing.B) {
32func BenchmarkRandomRune(b *testing.B) {
33 c := cyclingChar{}
33 c := cyclingChar{}
34−
34+
35 b.ResetTimer()
35 b.ResetTimer()
36 for i := 0; i < b.N; i++ {
36 for i := 0; i < b.N; i++ {
37 _ = c.randomRune()
37 _ = c.randomRune()
@@ -40,24 +40,24 @@ func BenchmarkRandomRune(b *testing.B) {
40
40
41func TestAnimationPerformance(t *testing.T) {
41func TestAnimationPerformance(t *testing.T) {
42 anim := New(30, "Performance test")
42 anim := New(30, "Performance test")
43−
43+
44 start := time.Now()
44 start := time.Now()
45 iterations := 1000
45 iterations := 1000
46−
46+
47 // Simulate rapid updates
47 // Simulate rapid updates
48 for i := 0; i < iterations; i++ {
48 for i := 0; i < iterations; i++ {
49 anim.Update(StepCharsMsg{id: anim.ID()})
49 anim.Update(StepCharsMsg{id: anim.ID()})
50 _ = anim.View()
50 _ = anim.View()
51 }
51 }
52−
52+
53 duration := time.Since(start)
53 duration := time.Since(start)
54 avgPerUpdate := duration / time.Duration(iterations)
54 avgPerUpdate := duration / time.Duration(iterations)
55−
55+
56 // Should complete 1000 updates in reasonable time
56 // Should complete 1000 updates in reasonable time
57 if avgPerUpdate > time.Millisecond {
57 if avgPerUpdate > time.Millisecond {
58 t.Errorf("Animation update too slow: %v per update (should be < 1ms)", avgPerUpdate)
58 t.Errorf("Animation update too slow: %v per update (should be < 1ms)", avgPerUpdate)
59 }
59 }
60−
60+
61− t.Logf("Animation performance: %v per update (%d updates in %v)",
61+ t.Logf("Animation performance: %v per update (%d updates in %v)",
62 avgPerUpdate, iterations, duration)
62 avgPerUpdate, iterations, duration)
63−}
63+}