Some checks failed
Checkout test / test (push) Successful in 7s
CI with Native Libraries / Check Build Environment (push) Successful in 13s
CI/CD Pipeline / Test (push) Failing after 5m8s
CI/CD Pipeline / Dev Compose Smoke Test (push) Has been skipped
CI/CD Pipeline / Build (push) Has been skipped
CI/CD Pipeline / Test Scripts (push) Has been skipped
CI/CD Pipeline / Security Scan (push) Failing after 4m51s
Documentation / build-and-publish (push) Failing after 37s
CI with Native Libraries / Build and Test Native Libraries (push) Failing after 14m38s
CI with Native Libraries / Build Release Libraries (push) Has been skipped
CI/CD Pipeline / Docker Build (push) Has been skipped
- Add websocket queue integration test - Add worker hash benchmark test - Add native detection script
56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
// Standalone benchmark for dataset hash operations
|
|
package worker_test
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/jfraeys/fetch_ml/internal/worker"
|
|
)
|
|
|
|
// BenchmarkSequentialHash profiles sequential directory hashing
|
|
func BenchmarkSequentialHash(b *testing.B) {
|
|
tmpDir := b.TempDir()
|
|
|
|
// Create test files
|
|
for i := 0; i < 50; i++ {
|
|
subdir := filepath.Join(tmpDir, "data", string(rune('a'+i%26)))
|
|
os.MkdirAll(subdir, 0750)
|
|
data := make([]byte, 100*1024) // 100KB each
|
|
os.WriteFile(filepath.Join(subdir, "chunk.bin"), data, 0640)
|
|
}
|
|
|
|
b.ResetTimer()
|
|
b.ReportAllocs()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
_, err := worker.DirOverallSHA256Hex(tmpDir)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
}
|
|
}
|
|
|
|
// BenchmarkParallelHash profiles parallel directory hashing
|
|
func BenchmarkParallelHash(b *testing.B) {
|
|
tmpDir := b.TempDir()
|
|
|
|
// Create test files
|
|
for i := 0; i < 50; i++ {
|
|
subdir := filepath.Join(tmpDir, "data", string(rune('a'+i%26)))
|
|
os.MkdirAll(subdir, 0750)
|
|
data := make([]byte, 100*1024) // 100KB each
|
|
os.WriteFile(filepath.Join(subdir, "chunk.bin"), data, 0640)
|
|
}
|
|
|
|
b.ResetTimer()
|
|
b.ReportAllocs()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
_, err := worker.DirOverallSHA256HexParallel(tmpDir)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
}
|
|
}
|