Skip to content

Commit

Permalink
test: add benchmark for decodeRuneInByteseq
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Apr 6, 2022
1 parent 5ed08bb commit f880398
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions byteseq_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package jx

import (
"testing"
"unicode/utf8"
)

func Benchmark_decodeRuneInByteseq(b *testing.B) {
var (
buf [4]byte
result rune
)
utf8.EncodeRune(buf[:], 'ж')

b.ReportAllocs()
b.ResetTimer()

for i := 0; i < b.N; i++ {
result, _ = decodeRuneInByteseq(buf[:])
}

if result != 'ж' {
b.Fatal(result)
}
}

0 comments on commit f880398

Please sign in to comment.