pub struct Benchmark { /* private fields */ }Expand description
A configured benchmark ready to run.
Create a Benchmark using Benchmark::builder() and then execute it with run().
§Examples
let results = Benchmark::builder()
.url("http://localhost:3000")
.concurrency(50)
.duration(Duration::from_secs(10))
.build()?
.run()
.await?;
results.print();Implementations§
Source§impl Benchmark
impl Benchmark
Sourcepub fn builder() -> BenchmarkBuilder
pub fn builder() -> BenchmarkBuilder
Create a new benchmark builder.
This is the entry point for configuring and running benchmarks.
§Examples
use httpress::Benchmark;
let builder = Benchmark::builder();Sourcepub async fn run(self) -> Result<BenchmarkResults>
pub async fn run(self) -> Result<BenchmarkResults>
Run the benchmark and return results.
Executes the configured benchmark, blocking until completion or interruption (Ctrl+C). Returns detailed metrics including latency statistics, throughput, and status codes.
§Errors
Returns an error if:
- The HTTP client cannot be initialized
- Network errors occur during execution (wrapped in results, not returned as error)
§Examples
let benchmark = Benchmark::builder()
.url("http://localhost:3000")
.requests(1000)
.build()?;
let results = benchmark.run().await?;
println!("Throughput: {:.2} req/s", results.throughput);
println!("p99 latency: {:?}", results.latency_p99);Auto Trait Implementations§
impl !Freeze for Benchmark
impl !RefUnwindSafe for Benchmark
impl Send for Benchmark
impl Sync for Benchmark
impl Unpin for Benchmark
impl UnsafeUnpin for Benchmark
impl !UnwindSafe for Benchmark
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more