Skip to content

Commit

Permalink
Benchmark. (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
ncruces authored May 12, 2023
1 parent 2d545c8 commit ec7733d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions bench/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
fastly "github.com/fastly/go-utils/strftime"
jehiah "github.com/jehiah/go-strftime"
lestrrat "github.com/lestrrat-go/strftime"
ncruces "github.com/ncruces/go-strftime"
tebeka "github.com/tebeka/strftime"
)

Expand Down Expand Up @@ -44,6 +45,21 @@ func BenchmarkFastly(b *testing.B) {
}
}

func BenchmarkNcruces(b *testing.B) {
var t time.Time
for i := 0; i < b.N; i++ {
ncruces.Format(benchfmt, t)
}
}

func BenchmarkNcrucesAppend(b *testing.B) {
var d []byte
var t time.Time
for i := 0; i < b.N; i++ {
d = ncruces.AppendFormat(d[:0], benchfmt, t)
}
}

func BenchmarkLestrrat(b *testing.B) {
var t time.Time
for i := 0; i < b.N; i++ {
Expand Down
3 changes: 2 additions & 1 deletion bench/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.16
require (
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239
github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869
github.com/lestrrat-go/strftime v1.0.3
github.com/lestrrat-go/strftime v1.0.6
github.com/ncruces/go-strftime v0.1.9
github.com/tebeka/strftime v0.1.5
)

0 comments on commit ec7733d

Please sign in to comment.