Skip to content

Commit

Permalink
add benchmark for csv detector allocs
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-vasile committed Aug 29, 2024
1 parent 31e6b1c commit d7081cc
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions internal/magic/text_csv_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package magic

import (
"io"
"math/rand"
"testing"
)

func BenchmarkCsv(b *testing.B) {
r := rand.New(rand.NewSource(0))
data := make([]byte, 4096)
if _, err := io.ReadFull(r, data); err != io.ErrUnexpectedEOF && err != nil {
b.Fatal(err)
}

b.ReportAllocs()
for i := 0; i < b.N; i++ {
Csv(data, 0)
}
}

0 comments on commit d7081cc

Please sign in to comment.