feat: rename profiler to performance, typeless event emitter

This commit is contained in:
2025-12-29 01:15:14 -05:00
parent c2b397a9f6
commit a2ce5b6897
6 changed files with 80 additions and 80 deletions

View File

@@ -0,0 +1,46 @@
package performance
import (
"os"
"path/filepath"
"runtime/pprof"
)
type Tracker struct {
File string
filePointer *os.File
Error error
}
func Track(file string) *Tracker {
return &Tracker{File: file}
}
func (t *Tracker) Start() {
var absPath string
absPath, t.Error = filepath.Abs(t.File)
if t.Error != nil {
return
}
t.Error = os.MkdirAll(filepath.Dir(absPath), 0777)
if t.Error != nil {
return
}
t.filePointer, t.Error = os.Create(absPath)
if t.Error != nil {
return
}
t.Error = pprof.StartCPUProfile(t.filePointer)
if t.Error != nil {
return
}
}
func (t *Tracker) End() {
pprof.StopCPUProfile()
t.filePointer.Close()
}