profiler

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package profiler provides functionality for the Tako framework.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventLog

type EventLog struct {
	Name      string
	Timestamp time.Time
}

EventLog ...

type HookMetric

type HookMetric struct {
	ID        string  `json:"id"`
	AvgTimeMs float64 `json:"avg_time_ms"`
	Calls     int     `json:"calls"`
}

HookMetric represents performance data for a single hook.

type MemoryHealth

type MemoryHealth struct {
	AllocMB      uint64
	SysMB        uint64
	NumGC        uint32
	NumGoroutine int           `json:"num_goroutine"`
	ActiveJobs   int           `json:"active_jobs"`
	Tickers      int           `json:"tickers"`
	PauseTotalNs uint64        `json:"pause_total_ns"`
	Uptime       time.Duration `json:"uptime"`

	Fps         float64 `json:"fps"`
	AvgUpdateMs float64 `json:"avg_update_ms"`
	AvgViewMs   float64 `json:"avg_view_ms"`

	FrameworkBootMs float64 `json:"framework_boot_ms"`
	AppBootMs       float64 `json:"app_boot_ms"`
	PluginsBootMs   float64 `json:"plugins_boot_ms"`
	TotalBootMs     float64 `json:"total_boot_ms"`

	HasRecordedMetrics bool `json:"has_recorded_metrics"`
	IsIdle             bool `json:"is_idle"`

	TotalEvents  int64   `json:"total_events"`
	EventsPerSec float64 `json:"events_per_sec"`
	TotalHooks   int     `json:"total_hooks"`

	HookMetrics []HookMetric `json:"hook_metrics"`
}

MemoryHealth returns current memory and goroutine stats.

type Profiler

type Profiler struct {
	// contains filtered or unexported fields
}

Profiler gathers and buffers profiler data.

func NewProfiler

func NewProfiler(ctx context.Context, bus contracts.EventBus, capacity int) *Profiler

NewProfiler creates a new Profiler.

func (*Profiler) ClearHookStats

func (c *Profiler) ClearHookStats(id string)

ClearHookStats removes profiling data for a specific hook.

func (*Profiler) GetEvents

func (c *Profiler) GetEvents() []EventLog

GetEvents returns a chronological list of recent events.

func (*Profiler) GetHealth

func (c *Profiler) GetHealth() MemoryHealth

GetHealth returns the current system health metrics.

func (*Profiler) GetPluginMetrics

func (c *Profiler) GetPluginMetrics(id string) *HookMetric

GetPluginMetrics returns metrics for a specific plugin ID.

func (*Profiler) RecordBootTimes

func (c *Profiler) RecordBootTimes(framework, app, plugins time.Duration)

RecordBootTimes logs framework, app, and total boot times.

func (*Profiler) RecordHook

func (c *Profiler) RecordHook(id string, dur time.Duration)

RecordHook logs the execution time of a hook.

func (*Profiler) RecordUpdate

func (c *Profiler) RecordUpdate(dur time.Duration)

RecordUpdate logs the duration of an Update cycle.

func (*Profiler) RecordView

func (c *Profiler) RecordView(dur time.Duration)

RecordView logs the duration of a View cycle and increments the frame counter.

func (*Profiler) Stop

func (c *Profiler) Stop()

Stop cleans up any resources or subscriptions held by the profiler.

func (*Profiler) Tick

func (c *Profiler) Tick()

Tick performs periodic metric calculations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL