add dev-only profiling with pprof, runtime/trace, and operation timing
Wire up Go's standard profiling toolkit so it's automatically available in dev builds and completely absent from production. The profiling package uses build tags (dev/!dev) to eliminate all pprof, trace, and timing code from release binaries with zero new dependencies. - backend/profiling: pprof HTTP server on :6060, /debug/trace endpoint, block/mutex profiling, and TimeOp helper for structured operation timing - scripts/profile.sh: interactive menu-driven script that auto-selects free ports (8080-8089) so multiple profiles can be open simultaneously - Instrumented key operations: app init, database init, player load/restore, queue set/restore - Makefile targets: profile, profile-cpu, profile-heap, profile-trace - .gitignore: exclude trace-*.out and *.pprof artifacts
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
"yellowjacket/backend/library"
|
||||
"yellowjacket/backend/player"
|
||||
"yellowjacket/backend/playlist"
|
||||
"yellowjacket/backend/profiling"
|
||||
"yellowjacket/backend/queue"
|
||||
)
|
||||
|
||||
@@ -43,6 +44,8 @@ func NewYellowJacketApp(
|
||||
logger *slog.Logger,
|
||||
assetHandler *assets.Handler,
|
||||
) (*YellowJacketApp, error) {
|
||||
defer profiling.TimeOp(logger, "app.NewYellowJacketApp")()
|
||||
|
||||
// initialize anything that does not need access to the wails runtime here
|
||||
yjApp := &YellowJacketApp{
|
||||
logger: logger,
|
||||
@@ -118,6 +121,8 @@ var startupErr error
|
||||
|
||||
// OnStartup initializes components that require the Wails runtime context.
|
||||
func (yj *YellowJacketApp) OnStartup(ctx context.Context) {
|
||||
defer profiling.TimeOp(yj.logger, "app.OnStartup")()
|
||||
|
||||
// initialize anything that needs to use the wails runtime AFTER its been initialized
|
||||
// you CANNOT use the wails runtime during this function
|
||||
yj.appContext = ctx
|
||||
|
||||
Reference in New Issue
Block a user