9 releases

0.2.0 Aug 12, 2024
0.1.1 Apr 14, 2024
0.1.1-alpha.1 Mar 26, 2024

#77 in Visualization

Download history 209/week @ 2024-08-16 219/week @ 2024-08-23 237/week @ 2024-08-30 204/week @ 2024-09-06 269/week @ 2024-09-13 208/week @ 2024-09-20 233/week @ 2024-09-27 194/week @ 2024-10-04 236/week @ 2024-10-11 204/week @ 2024-10-18 290/week @ 2024-10-25 511/week @ 2024-11-01 448/week @ 2024-11-08 387/week @ 2024-11-15 353/week @ 2024-11-22 113/week @ 2024-11-29

1,363 downloads per month
Used in flare-dht

MIT/Apache

84KB
2K SLoC

rlt

A Rust Load Testing framework with real-time tui support.

Crates.io Documentation Dependency status License

Screenshot

rlt 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.

Quick Start

Run cargo add rlt to add rlt as a dependency to your Cargo.toml:

[dependencies]
rlt = "0.1.1"

Then create your bench suite by implementing the BenchSuite trait. flatten attribute can be used to embed the predefined BenchCli into your own.

#[derive(Parser, Clone)]
pub struct HttpBench {
    /// Target URL.
    pub url: Url,

    /// Embed BenchCli into this Opts.
    #[command(flatten)]
    pub bench_opts: BenchCli,
}

#[async_trait]
impl BenchSuite for HttpBench {
    type WorkerState = Client;

    async fn state(&self, _: u32) -> Result<Self::WorkerState> {
        Ok(Client::new())
    }

    async fn bench(&mut self, client: &mut Self::WorkerState, _: &IterInfo) -> Result<IterReport> {
        let t = Instant::now();
        let resp = client.get(self.url.clone()).send().await?;
        let status = resp.status().into();
        let bytes = resp.bytes().await?.len() as u64;
        let duration = t.elapsed();
        Ok(IterReport { duration, status, bytes, items: 1 })
    }
}

You can also create a separate struct to hold the cli options for more flexibility. There is an example in examples/http_hyper.rs.

Finally, create the main function to run the load test:

#[tokio::main]
async fn main() -> Result<()> {
    let bs = HttpBench::parse();
    rlt::cli::run(bs.bench_opts, bs).await
}

More examples can be found in the examples directory.

Credits

The TUI layout in rlt is inspired by oha.

License

rlt is distributed under the terms of both the MIT License and the Apache License 2.0.

See the LICENSE-APACHE and LICENSE-MIT files for license details.

Dependencies

~11–25MB
~313K SLoC