Change module path from 'cburn' to 'github.com/theirongolddev/cburn' to enable standard Go remote installation: go install github.com/theirongolddev/cburn@latest This is a BREAKING CHANGE for any external code importing this module (though as a CLI tool, this is unlikely to affect anyone). All internal imports updated to use the new module path. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
93 lines
1.8 KiB
Go
93 lines
1.8 KiB
Go
package pipeline
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/theirongolddev/cburn/internal/source"
|
|
"github.com/theirongolddev/cburn/internal/store"
|
|
)
|
|
|
|
func BenchmarkLoad(b *testing.B) {
|
|
homeDir, _ := os.UserHomeDir()
|
|
claudeDir := filepath.Join(homeDir, ".claude")
|
|
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
result, err := Load(claudeDir, true, nil)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
_ = result
|
|
}
|
|
}
|
|
|
|
func BenchmarkParseFile(b *testing.B) {
|
|
homeDir, _ := os.UserHomeDir()
|
|
claudeDir := filepath.Join(homeDir, ".claude")
|
|
|
|
files, err := source.ScanDir(claudeDir)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
|
|
// Find the largest file for worst-case benchmarking
|
|
var biggest source.DiscoveredFile
|
|
var biggestSize int64
|
|
for _, f := range files {
|
|
info, err := os.Stat(f.Path)
|
|
if err != nil {
|
|
continue
|
|
}
|
|
if info.Size() > biggestSize {
|
|
biggestSize = info.Size()
|
|
biggest = f
|
|
}
|
|
}
|
|
|
|
b.Logf("Benchmarking largest file: %s (%.1f KB)", biggest.Path, float64(biggestSize)/1024)
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
result := source.ParseFile(biggest)
|
|
if result.Err != nil {
|
|
b.Fatal(result.Err)
|
|
}
|
|
}
|
|
}
|
|
|
|
func BenchmarkScanDir(b *testing.B) {
|
|
homeDir, _ := os.UserHomeDir()
|
|
claudeDir := filepath.Join(homeDir, ".claude")
|
|
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
files, err := source.ScanDir(claudeDir)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
_ = files
|
|
}
|
|
}
|
|
|
|
func BenchmarkLoadWithCache(b *testing.B) {
|
|
homeDir, _ := os.UserHomeDir()
|
|
claudeDir := filepath.Join(homeDir, ".claude")
|
|
|
|
cache, err := store.Open(CachePath())
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
defer func() { _ = cache.Close() }()
|
|
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
cr, err := LoadWithCache(claudeDir, true, cache, nil)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
_ = cr
|
|
}
|
|
}
|