From 9f7c49a04eaeb735f36f185a3947531a90cdabdd Mon Sep 17 00:00:00 2001 From: Julian Antonielli Date: Mon, 27 Feb 2023 12:12:37 +0000 Subject: [PATCH] Remove unused `wrk-api-bench` dependency (#2331) * Remove unused `wrk-api-bench` dependency * Remove benchmark file --- .../examples/pokemon-service/Cargo.toml | 1 - .../pokemon-service/tests/benchmark.rs | 58 ------------------- 2 files changed, 59 deletions(-) delete mode 100644 rust-runtime/aws-smithy-http-server/examples/pokemon-service/tests/benchmark.rs diff --git a/rust-runtime/aws-smithy-http-server/examples/pokemon-service/Cargo.toml b/rust-runtime/aws-smithy-http-server/examples/pokemon-service/Cargo.toml index da4cb284c0..b548c221f6 100644 --- a/rust-runtime/aws-smithy-http-server/examples/pokemon-service/Cargo.toml +++ b/rust-runtime/aws-smithy-http-server/examples/pokemon-service/Cargo.toml @@ -51,7 +51,6 @@ pokemon-service-server-sdk = { path = "../pokemon-service-server-sdk/" } assert_cmd = "2.0" home = "0.5" serial_test = "0.7.0" -wrk-api-bench = "0.0.8" # This dependency is only required for testing the `pokemon-service-tls` program. hyper-rustls = { version = "0.23.0", features = ["http2"] } diff --git a/rust-runtime/aws-smithy-http-server/examples/pokemon-service/tests/benchmark.rs b/rust-runtime/aws-smithy-http-server/examples/pokemon-service/tests/benchmark.rs deleted file mode 100644 index 4499854d79..0000000000 --- a/rust-runtime/aws-smithy-http-server/examples/pokemon-service/tests/benchmark.rs +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -use std::{env, fs::OpenOptions, io::Write, path::Path, time::Duration}; - -use tokio::time; -use wrk_api_bench::{BenchmarkBuilder, HistoryPeriod, WrkBuilder}; - -use crate::helpers::PokemonService; - -mod helpers; - -#[tokio::test] -async fn benchmark() -> Result<(), Box> { - // Benchmarks are expensive, so they run only if the environment - // variable `RUN_BENCHMARKS` is present. - if env::var_os("RUN_BENCHMARKS").is_some() { - let _program = PokemonService::run(); - // Give PokémonService some time to start up. - time::sleep(Duration::from_millis(50)).await; - - // The history directory is cached inside GitHub actions under - // the running use home directory to allow us to recover historical - // data between runs. - let history_dir = if env::var_os("GITHUB_ACTIONS").is_some() { - home::home_dir().unwrap().join(".wrk-api-bench") - } else { - Path::new(".").join(".wrk-api-bench") - }; - - let mut wrk = WrkBuilder::default() - .url(String::from("http://localhost:13734/empty-operation")) - .history_dir(history_dir) - .build()?; - - // Run a single benchmark with 8 threads and 64 connections for 60 seconds. - let benches = vec![BenchmarkBuilder::default() - .duration(Duration::from_secs(90)) - .threads(2) - .connections(32) - .build()?]; - wrk.bench(&benches)?; - - // Calculate deviation from last run and write it to disk. - if let Ok(deviation) = wrk.deviation(HistoryPeriod::Last) { - let mut deviation_file = OpenOptions::new() - .create(true) - .write(true) - .truncate(true) - .open("/tmp/smithy_rs_benchmark_deviation.txt") - .unwrap(); - deviation_file.write_all(deviation.to_github_markdown().as_bytes())?; - } - } - Ok(()) -}