Files
xscapes/siteframes_test.go
donlucasandClaude Fable 5.1 875ea8a481 The rainy window is animated on the page
A clip can now come from a study painter instead of a shore session: 24
frames at six a second, the work following one cosine from 0.1 to 0.9 and
back so the rain is seen at every density. The streaks fall six rows a second
through a pattern 24 rows tall, so the loop closes on itself: frame 24
differs from frame 0 in 5 cells, all the cat's breath, against 246 for one
step. It costs 17 KB gzipped; the page is 485 KB.

The checked-in rain still is gone; the aquarium still stays until its loop
is designed. allFX is the one list the page and the cost test both read.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-15 07:58:28 -07:00

52 lines
1.3 KiB
Go

package main
import (
"bytes"
"compress/gzip"
"testing"
"github.com/donlucasx/xscapes/internal/canvas"
)
// What every embedded animation costs, so the frame budget is chosen from
// numbers rather than guessed. GitHub Pages serves gzipped, so the gzipped
// column is the one a visitor waits for.
func TestWhatTheEmbeddedFramesCost(t *testing.T) {
gz := func(s string) int {
var b bytes.Buffer
w, _ := gzip.NewWriterLevel(&b, gzip.BestCompression)
w.Write([]byte(s))
w.Close()
return b.Len()
}
pal := &canvas.HTMLPalette{}
if truecolorFX {
t.Log("rendering TRUECOLOR")
}
totalRaw, totalGz := 0, 0
for _, cl := range allFX(pal) {
frames, cols, rows, _, err := framesOf(7, cl)
if err != nil {
t.Fatalf("%s: %v", cl.key, err)
}
raw := 0
for _, f := range frames {
raw += len(f)
}
all := ""
for _, f := range frames {
all += f
}
g := gz(all)
totalRaw += raw
totalGz += g
t.Logf("%-8s %3d frames %2dx%-3d raw %7d gzip %6d", cl.key, len(frames), cols, rows, raw, g)
}
t.Logf("palette: %d bytes of CSS, %d gzipped", len(pal.CSS()), gz(pal.CSS()))
totalGz += gz(pal.CSS())
t.Logf("TOTAL raw %d gzip %d (today's GIFs: 5,100,000 raw)", totalRaw, totalGz)
if totalGz > 900_000 {
t.Errorf("the embedded frames gzip to %d bytes, which is too much page to wait for", totalGz)
}
}