Rules-based browser launcher for TUI + GNOME. switchyard.aly.codes
tui gome bowser go
0

Configure Feed

Select the types of activity you want to include in your feed.

browserscan: add benchmark for many desktop files

Aly Raffauf (Jul 5, 2026, 10:59 PM EDT) b0cb84c4 7518bc5d

+44
+44
internal/browserscan/browserscan_test.go
··· 3 3 package browserscan 4 4 5 5 import ( 6 + "fmt" 6 7 "os" 7 8 "path/filepath" 8 9 "testing" ··· 271 272 } 272 273 } 273 274 } 275 + 276 + func BenchmarkInstalledManyDesktopFiles(b *testing.B) { 277 + home := filepath.Join(b.TempDir(), "applications") 278 + system := filepath.Join(b.TempDir(), "applications") 279 + orig := applicationsDirs 280 + applicationsDirs = func() []string { return []string{home, system} } 281 + b.Cleanup(func() { applicationsDirs = orig }) 282 + 283 + for i := range 500 { 284 + writeBenchmarkDesktop(b, home, fmt.Sprintf("browser-%03d.desktop", i), fmt.Sprintf(`[Desktop Entry] 285 + Type=Application 286 + Name=Browser %03d 287 + Icon=browser 288 + Exec=browser-%03d %%u 289 + MimeType=x-scheme-handler/http;x-scheme-handler/https; 290 + `, i, i)) 291 + writeBenchmarkDesktop(b, home, fmt.Sprintf("app-%03d.desktop", i), fmt.Sprintf(`[Desktop Entry] 292 + Type=Application 293 + Name=App %03d 294 + Exec=app-%03d 295 + MimeType=text/plain; 296 + `, i, i)) 297 + } 298 + 299 + b.ResetTimer() 300 + for b.Loop() { 301 + got := Installed() 302 + if len(got) != 500 { 303 + b.Fatalf("got %d browsers, want 500", len(got)) 304 + } 305 + } 306 + } 307 + 308 + func writeBenchmarkDesktop(b *testing.B, dir, rel, contents string) { 309 + b.Helper() 310 + path := filepath.Join(dir, filepath.FromSlash(rel)) 311 + if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { 312 + b.Fatalf("mkdir: %v", err) 313 + } 314 + if err := os.WriteFile(path, []byte(contents), 0o644); err != nil { 315 + b.Fatalf("write %s: %v", rel, err) 316 + } 317 + }