← 返回命令列表

Linux command

ballast 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Run load tests

ballast

Run load tests

ballast --no-snapshot

Run load tests

ballast --desc "[initial baseline]"

说明

ballast is a command-line tool for running snapshot-based performance tests against APIs. It applies the concept of snapshot testing, commonly used in UI testing frameworks, to API load testing. A performance baseline is captured as a snapshot and subsequent test runs are compared against it to detect performance regressions. Tests are defined in a ballast.json configuration file that specifies a list of endpoints to test. For each endpoint, ballast sends a configurable number of concurrent requests across multiple cycles and measures response times. It then computes average, minimum, and maximum response times and compares them against the previous snapshot. If the average response time deviates beyond a configurable threshold (default 250ms), the test is marked as failed. Beyond response time, ballast can validate expected HTTP status codes, response bodies, and response headers. A logarithmic ramp-up phase warms the target before the main test cycles begin. Results are displayed in the terminal with color-coded output: green for passing tests and improvements, red for failures and regressions, and yellow for warnings. Snapshots are stored in a .ballast_snapshot.json file in the current directory, maintaining a timestamped history of all previous test runs. Written in Rust, ballast uses tokio for async request execution and reqwest as its HTTP client.

参数

--no-snapshot
Run load tests without writing a snapshot file. Useful for one-off tests where no baseline comparison is needed.
--desc _description_
Attach a description to the snapshot for identification purposes.

FAQ

What is the ballast command used for?

ballast is a command-line tool for running snapshot-based performance tests against APIs. It applies the concept of snapshot testing, commonly used in UI testing frameworks, to API load testing. A performance baseline is captured as a snapshot and subsequent test runs are compared against it to detect performance regressions. Tests are defined in a ballast.json configuration file that specifies a list of endpoints to test. For each endpoint, ballast sends a configurable number of concurrent requests across multiple cycles and measures response times. It then computes average, minimum, and maximum response times and compares them against the previous snapshot. If the average response time deviates beyond a configurable threshold (default 250ms), the test is marked as failed. Beyond response time, ballast can validate expected HTTP status codes, response bodies, and response headers. A logarithmic ramp-up phase warms the target before the main test cycles begin. Results are displayed in the terminal with color-coded output: green for passing tests and improvements, red for failures and regressions, and yellow for warnings. Snapshots are stored in a .ballast_snapshot.json file in the current directory, maintaining a timestamped history of all previous test runs. Written in Rust, ballast uses tokio for async request execution and reqwest as its HTTP client.

How do I run a basic ballast example?

Run `ballast` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --no-snapshot do in ballast?

Run load tests without writing a snapshot file. Useful for one-off tests where no baseline comparison is needed.