iota_single_node_benchmark/
lib.rs

1// Copyright (c) Mysten Labs, Inc.
2// Modifications Copyright (c) 2024 IOTA Stiftung
3// SPDX-License-Identifier: Apache-2.0
4
5use crate::{benchmark_context::BenchmarkContext, command::Component, workload::Workload};
6
7pub(crate) mod benchmark_context;
8pub mod command;
9pub(crate) mod mock_account;
10pub(crate) mod mock_storage;
11pub(crate) mod single_node;
12pub(crate) mod tx_generator;
13pub mod workload;
14
15/// Benchmark a given workload on a specified component.
16/// The different kinds of workloads and components can be found in command.rs.
17/// \checkpoint_size represents both the size of a consensus commit, and size of
18/// a checkpoint if we are benchmarking the checkpoint.
19pub async fn run_benchmark(
20    workload: Workload,
21    component: Component,
22    checkpoint_size: usize,
23    print_sample_tx: bool,
24    skip_signing: bool,
25) {
26    let mut ctx = BenchmarkContext::new(workload.clone(), component, print_sample_tx).await;
27    let tx_generator = workload.create_tx_generator(&mut ctx).await;
28    let transactions = ctx.generate_transactions(tx_generator).await;
29    if matches!(component, Component::TxnSigning) {
30        ctx.benchmark_transaction_signing(transactions, print_sample_tx)
31            .await;
32        return;
33    }
34
35    let transactions = ctx.certify_transactions(transactions, skip_signing).await;
36    ctx.validator()
37        .assigned_shared_object_versions(&transactions)
38        .await;
39    match component {
40        Component::CheckpointExecutor => {
41            ctx.benchmark_checkpoint_executor(transactions, checkpoint_size)
42                .await;
43        }
44        Component::ExecutionOnly => {
45            ctx.benchmark_transaction_execution_in_memory(transactions, print_sample_tx)
46                .await;
47        }
48        _ => {
49            ctx.benchmark_transaction_execution(transactions, print_sample_tx)
50                .await;
51        }
52    }
53}