Skip to content

Commit

Permalink
pmatch binary now uses vk implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-m committed Dec 20, 2023
1 parent 7417ae8 commit a3d67a6
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions examples/pmatch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const (
)

func bench(fn func(), count int) {
// Warmup.
for i := 0; i < 10; i++ {
fn()
}

t0 := time.Now()
for i := 0; i < count; i++ {
fn()
Expand All @@ -33,10 +38,19 @@ func main() {
panic(err)
}

fn := pmatch.SearchRGBA
inst, err := pmatch.NewSearchVk(img.Bounds(), pat.Bounds(), img.Stride, pat.(*image.RGBA).Stride)
if err != nil {
panic(err)
}
defer inst.Destroy()

fn := inst.Run

// Test.
x, y, cos := fn(img, pat.(*image.RGBA))
x, y, cos, err := fn(img, pat.(*image.RGBA))
if err != nil {
panic(err)
}
fmt.Printf("x=%d y=%d cos=%f\n", x, y, cos)
if x != px {
panic("x detected incorrectly")
Expand Down

0 comments on commit a3d67a6

Please sign in to comment.