async fn benchmark_post_org_for_users_and_data(
    app_state: &AppState,
    server_handle: &dyn ServerHandle,
    concurrent_users: u32,
    sample_data: impl Iterator<Item = SampleResource>,
) -> Vec<
    std::result::Result<
        ServerOperationIterationState<ServerOperationIterationSucceeded>,
        ServerOperationIterationState<ServerOperationIterationFailed>,
    >,
> {
    /*
     * Build an iterator: One element for each iteration to run, run the operation for each iteration, and
     * count the iterations that failed.
     */
    let operations = sample_data.into_iter().map(|org| async {
        let operation_state = ServerOperationIterationState::new();
        let operation = run_operation_post_org(server_handle, operation_state.clone(), org);
        let operation = tokio::time::timeout(
            app_state
                .config
                .operation_timeout
                .to_std()
                .expect("unable to convert Duration"),
            operation,
        );

        // Having the timeout gives us a wrapped Result<Result ...>>. Un-nest them.
        let result = operation.await;
        let result = result.map_err(|err| {
            operation_state
                .completed()
                .failed(eyre!("Operation timed out: '{}'", err))
        });
        result.and_then(|wrapped_result| wrapped_result)
    });

    /*
     * Convert that iterator to a parallel stream, and use use `buffer_unordered(...)` to set it to run it only up to
     * `concurrent_users`, at once.
     */
    let mut operations = futures::stream::iter(operations)
        .buffer_unordered(usize::try_from(concurrent_users).unwrap());

    /*
     * Kick off the execution of the stream, summing up all of the failures that are encountered.
     */
    let mut results = vec![];
    while let Some(n) = operations.next().await {
        results.push(n);
    }

    results
}
/// Verifies and benchmarks FHIR `POST /Organization` operations for the specified number of concurrent users
/// using the specified sample data.
///
/// Parameters:
/// * `app_state`: the application's [AppState]
/// * `server_handle`: the [ServerHandle] for the server implementation instance being tested
/// * `concurrent_users`: the number of users to try and test with concurrently
/// * `sample_data`: the sample data to test against -- one iteration should be run for each element in it
///
/// Returns the number of iterations that failed.
Verifies and benchmarks FHIR `POST /Organization` operations for the specified number of concurrent users
using the specified sample data.



Returns the number of iterations that failed.
Verifies and benchmarks FHIR ` POST / Organization ` operations for the specified number of concurrent users using the specified sample data . Returns the number of iterations that failed .
async fn benchmark_post_org_for_users_and_data(
    app_state: &AppState,
    server_handle: &dyn ServerHandle,
    concurrent_users: u32,
    sample_data: impl Iterator<Item = SampleResource>,
) -> Vec<
    std::result::Result<
        ServerOperationIterationState<ServerOperationIterationSucceeded>,
        ServerOperationIterationState<ServerOperationIterationFailed>,
    >,
> {
    /*
     * Build an iterator: One element for each iteration to run, run the operation for each iteration, and
     * count the iterations that failed.
     */
    let operations = sample_data.into_iter().map(|org| async {
        let operation_state = ServerOperationIterationState::new();
        let operation = run_operation_post_org(server_handle, operation_state.clone(), org);
        let operation = tokio::time::timeout(
            app_state
                .config
                .operation_timeout
                .to_std()
                .expect("unable to convert Duration"),
            operation,
        );
        // Having the timeout gives us a wrapped Result<Result ...>>. Un-nest them.
        let result = operation.await;
        let result = result.map_err(|err| {
            operation_state
                .completed()
                .failed(eyre!("Operation timed out: '{}'", err))
        });
        result.and_then(|wrapped_result| wrapped_result)
    });
    /*
     * Convert that iterator to a parallel stream, and use use `buffer_unordered(...)` to set it to run it only up to
     * `concurrent_users`, at once.
     */
    let mut operations = futures::stream::iter(operations)
        .buffer_unordered(usize::try_from(concurrent_users).unwrap());
    /*
     * Kick off the execution of the stream, summing up all of the failures that are encountered.
     */
    let mut results = vec![];
    while let Some(n) = operations.next().await {
        results.push(n);
    }
    results
}
async fn benchmark_post_org_for_users_and_data ( app_state : & AppState , server_handle : & dyn ServerHandle , concurrent_users : u32 , sample_data : impl Iterator < Item = SampleResource > , ) -> Vec < std :: result :: Result < ServerOperationIterationState < ServerOperationIterationSucceeded > , ServerOperationIterationState < ServerOperationIterationFailed > , > , > { /*
     * Build an iterator: One element for each iteration to run, run the operation for each iteration, and
     * count the iterations that failed.
     */ let operations = sample_data . into_iter ( ) . map ( | org | async { let operation_state = ServerOperationIterationState :: new ( ) ; let operation = run_operation_post_org ( server_handle , operation_state . clone ( ) , org ) ; let operation = tokio :: time :: timeout ( app_state . config . operation_timeout . to_std ( ) . expect ( " " ) , operation , ) ; // Having the timeout gives us a wrapped Result<Result ...>>. Un-nest them. let result = operation . await ; let result = result . map_err ( | err | { operation_state . completed ( ) . failed ( eyre ! ( " " err ) ) } ) ; result . and_then ( | wrapped_result | wrapped_result ) } ) ; /*
     * Convert that iterator to a parallel stream, and use use `buffer_unordered(...)` to set it to run it only up to
     * `concurrent_users`, at once.
     */ let mut operations = futures :: stream :: iter ( operations ) . buffer_unordered ( usize :: try_from ( concurrent_users ) . unwrap ( ) ) ; /*
     * Kick off the execution of the stream, summing up all of the failures that are encountered.
     */ let mut results = vec ! [ ] ; while let Some ( n ) = operations . next ( ) . await { results . push ( n ) ; } results }
Verifies and benchmarks FHIR `POST /Organization` operations for the specified number of concurrent users
using the specified sample data.
Verifies and benchmarks FHIR ` POST / Organization ` operations for the specified number of concurrent users using the specified sample data .
app_state
&AppState
server_handle
&dyn ServerHandle
concurrent_users
u32
sample_data
impl Iterator<Item = SampleResource>
app_state
&AppState
server_handle
&dyn ServerHandle
concurrent_users
u32
sample_data
impl Iterator<Item = SampleResource>