@@ -7,7 +7,7 @@ import (
8func BenchmarkAnimationUpdate(b *testing.B) {
8func BenchmarkAnimationUpdate(b *testing.B) {
9 anim := New(30, "Loading test data")
9 anim := New(30, "Loading test data")
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) {
18func BenchmarkAnimationView(b *testing.B) {
18func BenchmarkAnimationView(b *testing.B) {
19 anim := New(30, "Loading test data")
19 anim := New(30, "Loading test data")
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()})
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) {
32func BenchmarkRandomRune(b *testing.B) {
32func BenchmarkRandomRune(b *testing.B) {
33 c := cyclingChar{}
33 c := cyclingChar{}
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) {
41func TestAnimationPerformance(t *testing.T) {
41func TestAnimationPerformance(t *testing.T) {
42 anim := New(30, "Performance test")
42 anim := New(30, "Performance test")
44 start := time.Now()
44 start := time.Now()
45 iterations := 1000
45 iterations := 1000
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()
53 duration := time.Since(start)
53 duration := time.Since(start)
54 avgPerUpdate := duration / time.Duration(iterations)
54 avgPerUpdate := duration / time.Duration(iterations)
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)
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)