Skip to content

Commit

Permalink
add BenchmarkLestrratCachedFormatBuffer, fix BenchmarkLestrratCachedW…
Browse files Browse the repository at this point in the history
…riter
  • Loading branch information
ianwilkes committed Jul 13, 2021
1 parent 2cf2db9 commit 50bb69c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions bench/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"testing"
"time"

jehiah "github.com/jehiah/go-strftime"
fastly "github.com/fastly/go-utils/strftime"
jehiah "github.com/jehiah/go-strftime"
lestrrat "github.com/lestrrat-go/strftime"
tebeka "github.com/tebeka/strftime"
)
Expand Down Expand Up @@ -67,12 +67,19 @@ func BenchmarkLestrratCachedWriter(b *testing.B) {
b.ResetTimer()

// This benchmark does not take into effect the compilation time
// nor the buffer reset time
for i := 0; i < b.N; i++ {
b.StopTimer()
buf.Reset()
b.StartTimer()
f.Format(&buf, t)
f.FormatString(t)
}
}

func BenchmarkLestrratCachedFormatBuffer(b *testing.B) {
var t time.Time
f, _ := lestrrat.New(benchfmt)
b.ResetTimer()

var buf []byte
for i := 0; i < b.N; i++ {
buf = f.FormatBuffer(buf[:0], t)
}
}

0 comments on commit 50bb69c

Please sign in to comment.