diff --git a/src/main.rs b/src/main.rs index 42e7d81e..0f564c5d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,8 @@ mod integration_tests; mod stats; mod wasm; +use std::fmt::Display; + // export for use by contract! macro use clap::Parser; pub use stats::{collect_block_stats, print_block_info, BlockInfo}; @@ -54,12 +56,28 @@ pub enum Contract { StorageReadWrite, } +impl Display for TargetPlatform { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", clap::ArgEnum::to_possible_value(self).unwrap_or("unknown".into()).get_name()) + } +} + +impl Display for Contract { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", clap::ArgEnum::to_possible_value(self).unwrap_or("unknown".into()).get_name()) + } +} + #[tokio::main] async fn main() -> color_eyre::Result<()> { color_eyre::install()?; let cli = Cli::parse(); tracing_subscriber::fmt::init(); + println!("Smart-bench run parameters:"); + println!("Platform: {}", cli.chain); + println!("Contracts: {}", cli.contracts.iter().map(|arg| arg.to_string()).collect::>().join("+")); + match cli.chain { TargetPlatform::InkWasm => wasm::exec(cli).await, TargetPlatform::SolWasm => wasm::exec(cli).await, diff --git a/stats/get_graph.sh b/stats/get_graph.sh index 12a754ae..fff040b7 100755 --- a/stats/get_graph.sh +++ b/stats/get_graph.sh @@ -8,6 +8,19 @@ DOCKER_COMPOSE_FILE="docker-compose.yml" HOST="localhost" GRAFANA_DASHBOARD_JSON="grafana-provisioning/dashboards/tps.json" +check_command() { + command -v "$1" >/dev/null 2>&1 && { $1 --version >/dev/null 2>&1; } +} + +if check_command "docker compose"; then + DOCKER_COMPOSE="docker compose" +elif check_command "docker-compose"; then + DOCKER_COMPOSE="docker-compose" +else + echo "Neither 'docker compose' nor 'docker-compose' could be found or are functional on your system." + exit 1 +fi + function echoerr() { echo "$@" 1>&2; } function usage { @@ -125,24 +138,24 @@ wait_for_containers() { local retry_interval=1 echo "Waiting for all Docker containers to be running..." - retry_command "$max_retries" "$retry_interval" docker compose -f "$DOCKER_COMPOSE_FILE" \ + retry_command "$max_retries" "$retry_interval" ${DOCKER_COMPOSE} -f "$DOCKER_COMPOSE_FILE" \ ps --services --filter "status=running" | grep -qvx " " } start_containers() { echo "Starting docker containers" - docker compose -f "$DOCKER_COMPOSE_FILE" up -d + ${DOCKER_COMPOSE} -f "$DOCKER_COMPOSE_FILE" up -d wait_for_containers } stop_containers() { echo "Stopping docker containers" - docker compose -f "$DOCKER_COMPOSE_FILE" down + ${DOCKER_COMPOSE} -f "$DOCKER_COMPOSE_FILE" down } print_containers_logs() { echo "Container logs -- START" - docker-compose -f "$DOCKER_COMPOSE_FILE" logs + ${DOCKER_COMPOSE} -f "$DOCKER_COMPOSE_FILE" logs echo "Container logs -- END" } @@ -158,7 +171,7 @@ convert_csv_to_line_protocol() { gsub(/ /,"\\ ", field); return field }{ - printf "%s,platform=%s,parachain_ver=%s,contract_type=%s,contract_compiler_ver=\"%s\" tx_per_sec=%s %s\n", + printf "%s,platform=\"%s\",parachain_ver=\"%s\",contract_type=\"%s\",contract_compiler_ver=\"%s\" tx_per_sec=%s %s\n", "tps", trim($2), trim($3), diff --git a/stats/smart_bench_to_csv.sh b/stats/smart_bench_to_csv.sh index 62def777..3991960d 100755 --- a/stats/smart_bench_to_csv.sh +++ b/stats/smart_bench_to_csv.sh @@ -7,12 +7,6 @@ SCRIPT_PATH=$(dirname "$(realpath -s "${BASH_SOURCE[0]}")") TIMESTAMP=$(date +%s) if [ -p /dev/stdin ]; then - PROCESS_LIST=$(ps -u) - CONTRACT_TYPE=$(echo "${PROCESS_LIST}" | grep -v grep | grep -oE "erc20|flipper|incrementer|erc721|erc1155|odd-product|triangle-number|storage-read|storage-write|storage-read-write") - PLATFORM=$(echo "${PROCESS_LIST}" | grep -v grep | grep -oE "ink-wasm|sol-wasm|evm") - - echo "${CONTRACT_TYPE}" - echo "${PLATFORM}" STATS=$(> "${CSV_OUTPUT}" +echo "${TIMESTAMP}, ${platform}, n/a, ${contract_types}, ${tps}, n/a, n/a" >> "${CSV_OUTPUT}"