Watch
1
0
Fork
You've already forked pkg-proxy
1
mirror of https://github.com/git-pkgs/proxy.git synced 2026-11-10 08:09:17 -05:00
pkg-proxy/internal/handler/npm_rewrite_bench_test.go

30 lines
652 B
Go
Raw Permalink Normal View History

package handler
import (
"testing"
"github.com/git-pkgs/proxy/internal/metadata/npm/npmbench"
)
func BenchmarkNPMRewriteMetadata(b *testing.B) {
body := npmbench.Packument(5000)
h := &NPMHandler{proxy: testProxy(), proxyURL: "http://proxy.example"}
b.SetBytes(int64(len(body)))
b.ReportAllocs()
for b.Loop() {
if _, _, err := h.rewriteMetadataKeeping("big", body); err != nil {
b.Fatal(err)
}
}
}
func BenchmarkNPMVersionTarball(b *testing.B) {
body := npmbench.Packument(5000)
b.SetBytes(int64(len(body)))
b.ReportAllocs()
for b.Loop() {
if npmVersionTarball(body, "1.0.2500") == "" {
b.Fatal("tarball not found")
}
}
}