x/model: add BenchmarkNameDisplay

Also, use range over int in other benchmarks.
This commit is contained in:
Blake Mizerany 2024-04-05 22:37:39 -07:00
parent f0e6c563e2
commit f2c17682b0

View File

@ -281,11 +281,22 @@ func TestParseNameAllocs(t *testing.T) {
func BenchmarkParseName(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
keep(ParseName("example.com/mistral:7b+Q4_0"))
}
}
func BenchmarkNameDisplay(b *testing.B) {
b.ReportAllocs()
r := ParseName("example.com/mistral:7b+Q4_0")
b.Run("Short", func(b *testing.B) {
for range b.N {
keep(r.DisplayShort())
}
})
}
func FuzzParseName(f *testing.F) {
f.Add("example.com/mistral:7b+Q4_0")
f.Add("example.com/mistral:7b+q4_0")