Expand description
Load testing utilities for stress testing request handlers.
Provides a configurable load generator that spawns concurrent request tasks and collects latency/error statistics.
§Example
use fastapi_core::loadtest::{LoadTest, LoadTestConfig, LoadTestReport};
use std::time::Duration;
let config = LoadTestConfig::new()
.total_requests(1000)
.concurrency(10);
let report = LoadTest::run(&config, |i| {
// Simulate request work (return Ok for success, Err for failure)
if i % 100 == 99 { Err("simulated error".into()) } else { Ok(()) }
});
assert!(report.success_rate() > 0.95);
println!("{report}");Structs§
- Load
Test - Load test runner.
- Load
Test Config - Configuration for a load test.
- Load
Test Report - Report from a completed load test.