Unverified Commit 950d855a authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Delete the orchestrator vs. middleware benchmark (#3158)

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
parent c869e869
Loading
Loading
Loading
Loading
+0 −2500

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −24
Original line number Diff line number Diff line
[package]
name = "orchestrator-vs-middleware"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
aws-config = { path = "../../build/aws-sdk/sdk/aws-config" }
aws-credential-types = { path = "../../build/aws-sdk/sdk/aws-credential-types", features = ["test-util"] }
aws-sdk-s3 = { path = "../../build/aws-sdk/sdk/s3" }
aws-smithy-client = { path = "../../build/aws-sdk/sdk/aws-smithy-client", features = ["test-util", "wiremock"] }
criterion = { version = "0.5", features = ["async_tokio"] }
http = "0.2.3"
middleware-s3 = { version = "0.28", package = "aws-sdk-s3", features = ["test-util"] }
middleware-smithy-client = { version = "0.55.3", package = "aws-smithy-client", features = ["test-util", "rustls"] }
tokio = { version = "1.23.1", features = ["macros", "test-util", "rt-multi-thread"] }

[profile.release]
debug = 1

[[bench]]
name = "middleware_vs_orchestrator"
harness = false
+0 −6
Original line number Diff line number Diff line
### Middleware vs. Orchestrator Benchmark

To run the benchmark:
```bash
./gradlew :aws:sdk:assemble && (cd aws/sdk/integration-tests/s3 && cargo bench)
```
+0 −101
Original line number Diff line number Diff line
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */

#[macro_use]
extern crate criterion;
use aws_sdk_s3 as s3;
use criterion::{BenchmarkId, Criterion};

macro_rules! test_connection {
    ($package:ident) => {
        $package::test_connection::infallible_connection_fn(|req| {
            assert_eq!(
                "https://test-bucket.s3.us-east-1.amazonaws.com/?list-type=2&prefix=prefix~",
                req.uri().to_string()
            );
            assert!(req.headers().contains_key("authorization"));
            http::Response::builder()
                .status(200)
                .body(
                    r#"<?xml version="1.0" encoding="UTF-8"?>
<ListBucketResult>
    <Name>test-bucket</Name>
    <Prefix>prefix~</Prefix>
    <KeyCount>1</KeyCount>
    <MaxKeys>1000</MaxKeys>
    <IsTruncated>false</IsTruncated>
    <Contents>
        <Key>some-file.file</Key>
        <LastModified>2009-10-12T17:50:30.000Z</LastModified>
        <Size>434234</Size>
        <StorageClass>STANDARD</StorageClass>
    </Contents>
</ListBucketResult>
"#,
                )
                .unwrap()
        })
    };
}

async fn orchestrator(client: &s3::Client) {
    let _output = client
        .list_objects_v2()
        .bucket("test-bucket")
        .prefix("prefix~")
        .send()
        .await
        .expect("successful execution");
}

async fn middleware(client: &middleware_s3::Client) {
    client
        .list_objects_v2()
        .bucket("test-bucket")
        .prefix("prefix~")
        .send()
        .await
        .expect("successful execution");
}

fn bench(c: &mut Criterion) {
    let orchestrator_client = {
        let conn = test_connection!(aws_smithy_client);
        let config = aws_sdk_s3::Config::builder()
            .credentials_provider(aws_sdk_s3::config::Credentials::for_tests())
            .region(aws_sdk_s3::config::Region::new("us-east-1"))
            .http_connector(conn.clone())
            .build();
        aws_sdk_s3::Client::from_conf(config)
    };
    let middleware_client = {
        let conn = test_connection!(middleware_smithy_client);
        let config = middleware_s3::Config::builder()
            .credentials_provider(middleware_s3::config::Credentials::for_tests())
            .region(middleware_s3::config::Region::new("us-east-1"))
            .http_connector(conn.clone())
            .build();
        middleware_s3::Client::from_conf(config)
    };

    let mut group = c.benchmark_group("compare");
    let param = "S3 ListObjectsV2";
    group.bench_with_input(
        BenchmarkId::new("middleware (last_release)", param),
        param,
        |b, _| {
            b.to_async(tokio::runtime::Runtime::new().unwrap())
                .iter(|| async { middleware(&middleware_client).await })
        },
    );
    group.bench_with_input(BenchmarkId::new("orchestrator", param), param, |b, _| {
        b.to_async(tokio::runtime::Runtime::new().unwrap())
            .iter(|| async { orchestrator(&orchestrator_client).await })
    });
    group.finish();
}

criterion_group!(benches, bench);
criterion_main!(benches);