perf

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildC2CRecordArgs

func BuildC2CRecordArgs(opts C2COptions) []string

BuildC2CRecordArgs builds perf c2c record command arguments for local execution.

func BuildC2CRecordCommand

func BuildC2CRecordCommand(opts C2COptions) string

BuildC2CRecordCommand builds perf c2c record command string for remote execution. It reuses BuildC2CRecordArgs and joins the arguments with proper shell escaping.

func BuildC2CReportArgs

func BuildC2CReportArgs(opts C2CReportOptions) []string

BuildC2CReportArgs builds perf c2c report command arguments for local execution.

func BuildC2CReportCommand

func BuildC2CReportCommand(opts C2CReportOptions) string

BuildC2CReportCommand builds perf c2c report command string for remote execution.

func BuildRecordArgs

func BuildRecordArgs(opts RecordOptions) []string

BuildRecordArgs builds perf record command arguments for local execution.

func BuildRecordCommand

func BuildRecordCommand(opts RecordOptions) string

BuildRecordCommand builds perf record command string for remote execution. It reuses BuildRecordArgs and joins the arguments with proper shell escaping.

func BuildStatArgs

func BuildStatArgs(opts StatOptions) []string

BuildStatArgs builds perf stat command arguments for local execution.

func BuildStatCommand

func BuildStatCommand(opts StatOptions) string

BuildStatCommand builds perf stat command string for remote execution. It reuses BuildStatArgs and joins the arguments with proper shell escaping.

func C2CCountFlag

func C2CCountFlag() cli.Flag

C2CCountFlag returns the count flag for perf c2c record (event period).

func C2CEventFlag

func C2CEventFlag() cli.Flag

C2CEventFlag returns the event flag for perf c2c record.

func C2CReportModeFlag

func C2CReportModeFlag() cli.Flag

C2CReportModeFlag returns the report mode flag for perf c2c report.

func C2CShowAllFlag

func C2CShowAllFlag() cli.Flag

C2CShowAllFlag returns the show-all flag for perf c2c report.

func ConvertPerfC2CToReport

func ConvertPerfC2CToReport(logger zerolog.Logger, perfDataPath string, runDir string, reportOpts C2CReportOptions, historyID string) (string, error)

ConvertPerfC2CToReport converts a local perf.data file to a c2c report. The report is saved to c2c-report.txt in the runDir. Returns the artifact filename (relative to runDir).

func DurationFlag

func DurationFlag() cli.Flag

DurationFlag returns the duration flag for performance data collection.

func ProcessC2CData

func ProcessC2CData(logger zerolog.Logger, sshClient *ssh.Client, remoteBaseDir string, runDir string, reportOpts C2CReportOptions, historyID string) (string, error)

ProcessC2CData processes perf c2c data from a remote host and creates a report. The report is saved to c2c-report.txt in the runDir. Returns the artifact filename (relative to runDir).

func ProfileCountFlag

func ProfileCountFlag() cli.Flag

ProfileCountFlag returns the count flag for perf record (event period).

func ProfileEventFlag

func ProfileEventFlag() cli.Flag

ProfileEventFlag returns the event flag for perf record (single event).

func StatDetailFlag

func StatDetailFlag() cli.Flag

StatDetailFlag returns the detail flag for perf stat.

func StatEventFlag

func StatEventFlag() cli.Flag

StatEventFlag returns the event flag for perf stat (multiple events).

Types

type BinaryArtifact

type BinaryArtifact struct {
	RemotePath string // Original path on remote
	LocalPath  string // Filename in history directory (e.g., "ABC123...XYZ.binary")
	Size       uint64 // File size in bytes
	Hash       string // Base32-encoded SHA256 hash
}

BinaryArtifact represents a binary that was copied for the profile.

func ConvertPerfToPprof

func ConvertPerfToPprof(logger zerolog.Logger, perfDataPath string, outputPath string, runDir string, historyID string) ([]BinaryArtifact, error)

ConvertPerfToPprof converts a local perf.data file to pprof format. The perf script output is written to a temporary file that is deleted after processing. Returns a list of binaries that were copied for artifact registration. Binaries are stored as <base32-sha256>.<basename>.binary in runDir.

func ProcessPerfData

func ProcessPerfData(logger zerolog.Logger, sshClient *ssh.Client, remoteBaseDir string, outputPath string, runDir string, pids []string, historyID string) ([]BinaryArtifact, error)

ProcessPerfData processes perf data from a remote host and creates a pprof profile. It resolves binary paths through /proc/<pid>/root for containerized processes. The perf script output is written to a temporary file that is deleted after processing. Returns a list of binaries that were copied for artifact registration. Binaries are stored as <base32-sha256>.binary in runDir.

type C2COptions

type C2COptions struct {
	Event      string   // Event to record (platform-specific default if empty)
	Count      int      // Event period to sample (e.g., -c 1000000)
	PIDs       []string // Process IDs to attach to
	Duration   int      // Duration in seconds (used with sleep)
	OutputPath string   // Output file path (default: perf.data)
	Binary     string   // Binary to execute (mutually exclusive with PIDs)
	Args       []string // Arguments for the binary
}

C2COptions contains options for perf c2c record command.

type C2CReportOptions

type C2CReportOptions struct {
	InputPath string // Input perf.data file path
	Mode      string // Report mode: "stdio" (text) or "tui" (interactive)
	ShowAll   bool   // Show all captured entries (--show-all)
	NoSource  bool   // Don't show source line information (--no-source)
	ShowCPU   bool   // Show CPU information (--show-cpu-cnt)
}

C2CReportOptions contains options for perf c2c report command.

type RecordOptions

type RecordOptions struct {
	Event      string   // Event to record
	Count      int      // Event period to sample (e.g., -c 1000000)
	PIDs       []string // Process IDs to attach to
	Duration   int      // Duration in seconds (used with sleep)
	OutputPath string   // Output file path (default: perf.data)
	Binary     string   // Binary to execute (mutually exclusive with PIDs)
	Args       []string // Arguments for the binary
}

RecordOptions contains options for perf record command.

type StatOptions

type StatOptions struct {
	Events   []string // Events to measure
	PIDs     []string // Process IDs to attach to
	Duration int      // Duration in seconds (used with sleep)
	Binary   string   // Binary to execute (mutually exclusive with PIDs)
	Args     []string // Arguments for the binary
	Detail   bool     // Add detailed statistics (-d flag)
}

StatOptions contains options for perf stat command.

Jump to

Keyboard shortcuts

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