mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
Source files keep their SPDX-License-Identifier and Hanzo copyright line; the Gitea, Gogs and LFS Test Server copyrights they used to repeat now live once in NOTICE, alongside LICENSE. The header lint accepts any copyright line above the SPDX line, so it no longer demands an upstream one. Co-authored-by: Hanzo Dev <[email protected]>
33 lines
791 B
Go
33 lines
791 B
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package util
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCallerFuncName(t *testing.T) {
|
|
s := CallerFuncName()
|
|
assert.Equal(t, "github.com/hanzoai/git/modules/util.TestCallerFuncName", s)
|
|
}
|
|
|
|
func BenchmarkCallerFuncName(b *testing.B) {
|
|
// BenchmarkCaller/sprintf-12 12744829 95.49 ns/op
|
|
b.Run("sprintf", func(b *testing.B) {
|
|
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 b.Loop() {
|
|
CallerFuncName()
|
|
}
|
|
})
|
|
}
|