matrix

package
v0.1.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildStaticBinary

func BuildStaticBinary(outputPath string) error

BuildStaticBinary builds a static binary for Linux that can run in Docker containers

func ExtractRepoName

func ExtractRepoName(repoURL string) string

ExtractRepoName extracts the repository name from a URL

func ParseIntList added in v0.1.2

func ParseIntList(str string) ([]int, error)

ParseIntList parses a comma-separated string of integers like "2,4,8,16" into []int

func PrintAllGraphs added in v0.1.2

func PrintAllGraphs(result *MatrixResult)

PrintAllGraphs prints multiple graphs for "all" benchmark mode One graph per RAM value showing CPU scaling, and one graph per CPU value showing RAM scaling

func PrintBuildTimeGraph

func PrintBuildTimeGraph(result *MatrixResult)

PrintBuildTimeGraph prints an ASCII bar chart of build time based on benchmark type

func PrintSummaryTable

func PrintSummaryTable(result *MatrixResult)

PrintSummaryTable prints a formatted summary table to the console

func SaveSummaryCSV

func SaveSummaryCSV(result *MatrixResult, filename string) error

SaveSummaryCSV saves the matrix results as CSV

func SaveSummaryJSON

func SaveSummaryJSON(result *MatrixResult, filename string) error

SaveSummaryJSON saves the matrix results as JSON

func SaveSummaryMarkdown

func SaveSummaryMarkdown(result *MatrixResult, filename string) error

SaveSummaryMarkdown saves the matrix results as Markdown

Types

type BenchmarkType added in v0.1.2

type BenchmarkType string

BenchmarkType represents the type of matrix benchmark being run

const (
	BenchmarkTypeCustom   BenchmarkType = "custom"
	BenchmarkTypeSweepCPU BenchmarkType = "sweep-cpu"
	BenchmarkTypeSweepRAM BenchmarkType = "sweep-ram"
	BenchmarkTypeAll      BenchmarkType = "all"
)

type Config

type Config struct {
	Image      string           // Docker image name
	RepoURL    string           // Git repository URL to clone
	Command    string           // Benchmark command to run
	Runs       int              // Number of benchmark runs per configuration
	OutputDir  string           // Directory to save output files
	Name       string           // Benchmark name for reports
	Configs    []ResourceConfig // CPU/RAM configurations to test
	SkipWarmup bool             // Skip warm-up run
	Debug      bool             // Enable debug logging with real-time output
	Type       BenchmarkType    // Type of benchmark (custom, sweep-cpu, sweep-ram, all)
	FixedCPU   int              // For sweep-ram: the fixed CPU value
	FixedRAM   int              // For sweep-cpu: the fixed RAM value
	CPUList    []int            // For all: list of CPU values tested
	RAMList    []int            // For all: list of RAM values tested
}

Config holds the matrix benchmark configuration

func (Config) RepoName

func (c Config) RepoName() string

RepoName extracts the repository name from the RepoURL

type ConfigResult

type ConfigResult struct {
	Config      ResourceConfig
	Success     bool
	Error       string
	Mean        float64 // Mean duration in seconds
	Median      float64 // Median duration in seconds
	StdDev      float64 // Standard deviation in seconds
	Min         float64 // Minimum duration in seconds
	Max         float64 // Maximum duration in seconds
	P90         float64 // 90th percentile in seconds
	P95         float64 // 95th percentile in seconds
	SuccessRate float64 // Percentage of successful runs
	TotalRuns   int     // Total number of runs attempted
	SuccessRuns int     // Number of successful runs
}

ConfigResult holds the result for a single configuration

type Container

type Container struct {
	ID string
	// contains filtered or unexported fields
}

Container represents a running Docker container

func (*Container) CopyDirFromContainer

func (c *Container) CopyDirFromContainer(ctx context.Context, srcPath, dstPath string) error

CopyDirFromContainer copies a directory from the container to the host

func (*Container) CopyFileFromContainer

func (c *Container) CopyFileFromContainer(ctx context.Context, srcPath, dstPath string) error

CopyFileFromContainer copies a file from the container to the host

func (*Container) CopyFileToContainer

func (c *Container) CopyFileToContainer(ctx context.Context, srcPath, dstPath string) error

CopyFileToContainer copies a file from the host to the container

func (*Container) CopyFileToContainerWithDebug

func (c *Container) CopyFileToContainerWithDebug(ctx context.Context, srcPath, dstPath string, debug bool) error

CopyFileToContainerWithDebug copies a file from the host to the container with optional debug logging

func (*Container) Exec

func (c *Container) Exec(ctx context.Context, cmd []string, workDir string) (*ExecResult, error)

Exec executes a command in the container and returns the result

func (*Container) ExecShell

func (c *Container) ExecShell(ctx context.Context, command string, workDir string) (*ExecResult, error)

ExecShell executes a shell command in the container

func (*Container) ExecShellStreaming

func (c *Container) ExecShellStreaming(ctx context.Context, command string, workDir string, debug bool) (*ExecResult, error)

ExecShellStreaming executes a shell command in the container with real-time output streaming

func (*Container) ExecShellWithDebug

func (c *Container) ExecShellWithDebug(ctx context.Context, command string, workDir string, debug bool) (*ExecResult, error)

ExecShellWithDebug executes a shell command with optional debug logging (non-streaming)

func (*Container) Stop

func (c *Container) Stop(ctx context.Context) error

Stop stops and removes the container

type ContainerConfig

type ContainerConfig struct {
	Image      string
	CPUs       int
	Memory     int // GB
	WorkingDir string
	MountPath  string // Host path to mount at /workspace
}

ContainerConfig holds configuration for creating a container

type DockerClient

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

DockerClient wraps the Docker SDK client

func NewDockerClient

func NewDockerClient() (*DockerClient, error)

NewDockerClient creates a new Docker client

func (*DockerClient) Close

func (d *DockerClient) Close() error

Close closes the Docker client

func (*DockerClient) CreateContainer

func (d *DockerClient) CreateContainer(ctx context.Context, cfg ContainerConfig) (*Container, error)

CreateContainer creates and starts a new container with resource limits

func (*DockerClient) CreateContainerWithDebug

func (d *DockerClient) CreateContainerWithDebug(ctx context.Context, cfg ContainerConfig, debug bool) (*Container, error)

CreateContainerWithDebug creates and starts a new container with resource limits and optional debug logging

func (*DockerClient) EnsureImage

func (d *DockerClient) EnsureImage(ctx context.Context, imageName string) error

EnsureImage checks if the image exists locally, pulls if not

type ExecResult

type ExecResult struct {
	ExitCode int
	Stdout   string
	Stderr   string
}

ExecResult holds the result of executing a command in a container

type MatrixResult

type MatrixResult struct {
	Config  Config
	Results []ConfigResult
}

MatrixResult holds the complete matrix benchmark results

func Run

func Run(ctx context.Context, config Config, binaryPath string) (*MatrixResult, error)

Run executes the matrix benchmark with all configurations sequentially binaryPath should be a path to a Linux-compatible caliper binary

type ResourceConfig

type ResourceConfig struct {
	CPUs   int // Number of CPUs
	Memory int // RAM in GB
}

ResourceConfig represents a single CPU/RAM configuration

func GenerateGridConfigs added in v0.1.2

func GenerateGridConfigs(cpus []int, rams []int) []ResourceConfig

GenerateGridConfigs creates configs for all CPU x RAM combinations Ordered by CPU first, then RAM (e.g., 2:8, 2:16, 2:32, 4:8, 4:16, ...)

func GenerateSweepCPUConfigs added in v0.1.2

func GenerateSweepCPUConfigs(cpus []int, fixedRAM int) []ResourceConfig

GenerateSweepCPUConfigs creates configs with varying CPUs and fixed RAM

func GenerateSweepRAMConfigs added in v0.1.2

func GenerateSweepRAMConfigs(rams []int, fixedCPU int) []ResourceConfig

GenerateSweepRAMConfigs creates configs with varying RAM and fixed CPU

func ParseConfigs

func ParseConfigs(configStr string) ([]ResourceConfig, error)

ParseConfigs parses a config string like "2:8,4:16,8:32" into ResourceConfig slice

func (ResourceConfig) DirName

func (r ResourceConfig) DirName() string

DirName returns a directory-safe name for the config

func (ResourceConfig) String

func (r ResourceConfig) String() string

String returns a human-readable representation of the config

Jump to

Keyboard shortcuts

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