mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-08-27 03:42:49 +00:00
Add not_index_byte and not_index_byte2 functions to simdstring package
Fixes #9646
This commit is contained in:
parent
d8af7e2c88
commit
f4bf9cf1c9
5 changed files with 231 additions and 0 deletions
|
|
@ -64,3 +64,45 @@ func BenchmarkIndexByte2(b *testing.B) {
|
|||
t(pos, "scalar")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkNotIndexByte(b *testing.B) {
|
||||
t := func(pos int, which string) {
|
||||
// Fill with 'a' and place 'q' (a non-matching byte) at the target position
|
||||
data := haystack('a', 'q', pos)
|
||||
f := NotIndexByte
|
||||
switch which {
|
||||
case "scalar":
|
||||
f = not_index_byte_scalar
|
||||
}
|
||||
b.Run(fmt.Sprintf("%s_sz=%d", which, pos), func(b *testing.B) {
|
||||
for b.Loop() {
|
||||
f(data, 'a')
|
||||
}
|
||||
})
|
||||
}
|
||||
for _, pos := range sizes {
|
||||
t(pos, "simdstring")
|
||||
t(pos, "scalar")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkNotIndexByte2(b *testing.B) {
|
||||
t := func(pos int, which string) {
|
||||
// Fill with 'a' and place 'q' (neither 'a' nor 'x') at the target position
|
||||
data := haystack('a', 'q', pos)
|
||||
f := NotIndexByte2
|
||||
switch which {
|
||||
case "scalar":
|
||||
f = not_index_byte2_scalar
|
||||
}
|
||||
b.Run(fmt.Sprintf("%s_sz=%d", which, pos), func(b *testing.B) {
|
||||
for b.Loop() {
|
||||
f(data, 'a', 'x')
|
||||
}
|
||||
})
|
||||
}
|
||||
for _, pos := range sizes {
|
||||
t(pos, "simdstring")
|
||||
t(pos, "scalar")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue