### Implement BenchSuite Trait for Custom Load Testing Source: https://github.com/wfxr/rlt/blob/main/README.md This Rust code defines a custom `HttpBench` struct using `clap::Parser` to handle command-line arguments, including a target URL and embedded `BenchCli` options. It then implements the `BenchSuite` trait, specifying `Client` as the worker state and defining the asynchronous `bench` method. The `bench` method performs an HTTP GET request, measures the duration, status, and bytes received, and returns an `IterReport` for each iteration. ```Rust #[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 { Ok(Client::new()) } async fn bench(&mut self, client: &mut Self::WorkerState, _: &IterInfo) -> Result { 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 }) } } ``` -------------------------------- ### Run rlt Load Test from Main Function Source: https://github.com/wfxr/rlt/blob/main/README.md This Rust code snippet illustrates the main function for a load test application using rlt. It uses `tokio::main` for asynchronous execution, parses the `HttpBench` command-line arguments, and then calls `rlt::cli::run` to execute the load test using the parsed options and the custom `HttpBench` suite. ```Rust #[tokio::main] async fn main() -> Result<()> { let bs = HttpBench::parse(); rlt::cli::run(bs.bench_opts, bs).await } ``` -------------------------------- ### Add rlt Dependency to Cargo.toml Source: https://github.com/wfxr/rlt/blob/main/README.md Instructions to add the rlt crate as a dependency to your Rust project's Cargo.toml file, specifying version 0.1.1. This is the first step to integrate rlt into your project. ```TOML [dependencies] rlt = "0.1.1" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.