helpers: Add a basic benchmark for RelURL

This commit is contained in:
Bjørn Erik Pedersen 2023-06-12 14:43:35 +02:00
parent b7dc93ca11
commit 5db215d4d6
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F

View file

@ -149,7 +149,7 @@ func TestRelURL(t *testing.T) {
}
}
func doTestRelURL(t *testing.T, defaultInSubDir, addLanguage, multilingual bool, lang string) {
func doTestRelURL(t testing.TB, defaultInSubDir, addLanguage, multilingual bool, lang string) {
t.Helper()
c := qt.New(t)
v := config.New()
@ -262,3 +262,13 @@ func TestSanitizeURL(t *testing.T) {
}
}
}
func BenchmarkRelURL(b *testing.B) {
v := config.New()
v.Set("baseURL", "http://base/")
p := newTestPathSpecFromCfgAndLang(v, "")
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = p.RelURL("https://base/foo/bar", false)
}
}