Use test context in tests and new loop system in benchmarks (#33648)
Replace all contexts in tests with go1.24 t.Context() --------- Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
3bbc482879
commit
cc1fdc84ca
108 changed files with 712 additions and 794 deletions
|
@ -18,14 +18,14 @@ func TestCallerFuncName(t *testing.T) {
|
|||
func BenchmarkCallerFuncName(b *testing.B) {
|
||||
// BenchmarkCaller/sprintf-12 12744829 95.49 ns/op
|
||||
b.Run("sprintf", func(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
for b.Loop() {
|
||||
_ = fmt.Sprintf("aaaaaaaaaaaaaaaa %s %s %s", "bbbbbbbbbbbbbbbbbbb", b.Name(), "ccccccccccccccccccccc")
|
||||
}
|
||||
})
|
||||
// BenchmarkCaller/caller-12 10625133 113.6 ns/op
|
||||
// It is almost as fast as fmt.Sprintf
|
||||
b.Run("caller", func(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
for b.Loop() {
|
||||
CallerFuncName(1)
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue