summaryrefslogtreecommitdiff
path: root/internal/log/caller_test.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2022-09-29 11:02:12 +0100
committerLibravatar GitHub <noreply@github.com>2022-09-29 12:02:12 +0200
commit2f22780800915b5d5262aea1754ecce44f752db7 (patch)
treed81d8a0210cfac93cfdcc04e20e49728f14ef01c /internal/log/caller_test.go
parent[chore] update dependencies, bump to Go 1.19.1 (#826) (diff)
downloadgotosocial-2f22780800915b5d5262aea1754ecce44f752db7.tar.xz
[chore] simplify generating log entry caller information (#863)
* vastly simplify logging caller information Signed-off-by: kim <grufwub@gmail.com> * fix failing test due to multiple calls to processor.Start() Signed-off-by: kim <grufwub@gmail.com> Signed-off-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/log/caller_test.go')
-rw-r--r--internal/log/caller_test.go54
1 files changed, 0 insertions, 54 deletions
diff --git a/internal/log/caller_test.go b/internal/log/caller_test.go
deleted file mode 100644
index 59bf342d1..000000000
--- a/internal/log/caller_test.go
+++ /dev/null
@@ -1,54 +0,0 @@
-package log_test
-
-import (
- "runtime"
- "strings"
- "testing"
-
- "codeberg.org/gruf/go-atomics"
- "github.com/superseriousbusiness/gotosocial/internal/log"
-)
-
-// noopt exists to prevent certain optimisations during benching.
-var noopt = atomics.NewString()
-
-func BenchmarkCaller(b *testing.B) {
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- name := log.Caller(2)
- noopt.Store(name)
- }
- })
-}
-
-func BenchmarkCallerNoCache(b *testing.B) {
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- var rpc [1]uintptr
-
- // Fetch pcs of callers
- n := runtime.Callers(2, rpc[:])
-
- if n > 0 {
- // Fetch frame info for caller pc
- frame, _ := runtime.CallersFrames(rpc[:]).Next()
-
- if frame.PC != 0 {
- name := frame.Function
-
- // Drop all but the package name and function name, no mod path
- if idx := strings.LastIndex(name, "/"); idx >= 0 {
- name = name[idx+1:]
- }
-
- // Drop any generic type parameter markers
- if idx := strings.Index(name, "[...]"); idx >= 0 {
- name = name[:idx] + name[idx+5:]
- }
-
- noopt.Store(name)
- }
- }
- }
- })
-}