INNER CODE UNIT · Rust

num_chunks

cloudflare/workers-rs · benchmark/src/lib.rs:22

    let num_chunks = (1024 * 1024) / chunk_size; // 128 chunks
    let chunk = vec![b'x'; chunk_size];

    // Create a stream that yields the data
    let data_stream =
        stream::iter((0..num_chunks).map(move |_| Ok::<Vec<u8>, worker::Error>(chunk.clone())));

    Response::from_stream(data_stream)
}

/// Main benchmark handler that makes 10 parallel sub-requests
async fn handle_benchmark(url: &Url) -> Result<Response> {
    // Get the base URL from the request
    let base_url = format!(
        "{}://{}",
        url.scheme(),
        url.host_str().unwrap_or("localhost")
    );

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…