Crate rlt

Source
Expand description

A universal load testing library for Rust, with real-time tui support.

This crate provides a simple way to create load test tools in Rust. It is designed to be a universal load test framework, which means you can use rlt for various services, such as Http, gRPC, Thrift, Database, or other customized services.

§Features

  • Flexible: Customize the work load with your own logic.
  • Easy to use: Little boilerplate code, just focus on testing.
  • Rich Statistics: Collect and display rich statistics.
  • High performance: Optimized for performance and resource usage.
  • Real-time TUI: Monitor testing progress with a powerful real-time TUI.

§Example

A simple example of a stateless bench suite:

use anyhow::Result;
use async_trait::async_trait;
use clap::Parser;
use rlt::{cli::BenchCli, IterInfo, IterReport, StatelessBenchSuite, Status};
use tokio::time::Instant;

#[derive(Clone)]
struct SimpleBench;

#[async_trait]
impl StatelessBenchSuite for SimpleBench {
    async fn bench(&mut self, _: &IterInfo) -> Result<IterReport> {
        let t = Instant::now();
        // do the work here
        let duration = t.elapsed();

        let report = IterReport {
            duration,
            status: Status::success(0),
            bytes: 42, // bytes processed in current iteration
            items: 5,  // items processed in current iteration
        };
        Ok(report)
    }
}

#[tokio::main]
async fn main() -> Result<()> {
    rlt::cli::run(BenchCli::parse(), SimpleBench).await
}

Stateful bench is also supported, see the examples/http_reqwest.

Modules§

cli
This module provides a CLI interface for the benchmark tool.
collector
This module defines a trait for collecting iteration results.
reporter
This module defines a trait for printing benchmark reports.

Structs§

BenchReport
The final benchmark report.
IterInfo
Information about the current iteration.
IterReport
The iteration report.
Status
The iteration status.

Enums§

StatusKind
Represents the kind of status.

Traits§

BenchSuite
A trait for benchmark suites.
StatelessBenchSuite
A trait for stateless benchmark suites.

Functions§

tui_tracing_subscriber_layer