sui_single_node_benchmark/
command.rs1use clap::{Parser, Subcommand, ValueEnum};
5use std::path::PathBuf;
6use strum_macros::EnumIter;
7
8#[derive(Parser)]
9#[clap(
10 name = "sui-single-node-benchmark",
11 about = "Benchmark a single validator node",
12 rename_all = "kebab-case",
13 author,
14 version
15)]
16pub struct Command {
17 #[arg(
18 long,
19 default_value_t = 500000,
20 help = "Number of transactions to submit"
21 )]
22 pub tx_count: u64,
23 #[arg(
24 long,
25 default_value_t = 100,
26 help = "Number of transactions in a consensus commit/checkpoint"
27 )]
28 pub checkpoint_size: usize,
29 #[arg(
30 long,
31 help = "Whether to print out a sample transaction and effects that is going to be benchmarked on"
32 )]
33 pub print_sample_tx: bool,
34 #[arg(
35 long,
36 default_value = "baseline",
37 ignore_case = true,
38 help = "Which component to benchmark"
39 )]
40 pub component: Component,
41 #[clap(subcommand)]
42 pub workload: WorkloadKind,
43}
44
45#[derive(Copy, Clone, EnumIter, ValueEnum)]
46pub enum Component {
47 ExecutionOnly,
48 Baseline,
50 WithTxManager,
52 ValidatorWithoutConsensus,
55 ValidatorWithFakeConsensus,
60 CheckpointExecutor,
63}
64
65#[derive(Subcommand, Clone)]
66pub enum WorkloadKind {
67 PTB {
68 #[arg(
69 long,
70 default_value_t = 0,
71 help = "Number of address owned input objects per transaction.\
72 This represents the amount of DB reads per transaction prior to execution."
73 )]
74 num_transfers: u64,
75 #[arg(
76 long,
77 default_value_t = false,
78 help = "When transferring an object, whether to use native TransferObjecet command, or to use Move code for the transfer"
79 )]
80 use_native_transfer: bool,
81 #[arg(
82 long,
83 default_value_t = 0,
84 help = "Number of dynamic fields read per transaction.\
85 This represents the amount of runtime DB reads per transaction during execution."
86 )]
87 num_dynamic_fields: u64,
88 #[arg(
89 long,
90 default_value_t = 0,
91 help = "Computation intensity per transaction.\
92 The transaction computes the n-th Fibonacci number \
93 specified by this parameter * 100."
94 )]
95 computation: u8,
96 #[arg(
97 long,
98 default_value_t = 0,
99 help = "Whether to use shared objects in the transaction.\
100 If 0, no shared objects will be used.\
101 Otherwise `v` shared objects will be created and each transaction will use these `v` shared objects."
102 )]
103 num_shared_objects: usize,
104 #[arg(
105 long,
106 default_value_t = 0,
107 help = "How many NFTs to mint/transfer during the transaction.\
108 If 0, no NFTs will be minted.\
109 Otherwise `v` NFTs with the specified size will be created and transferred to the sender"
110 )]
111 num_mints: u16,
112 #[arg(
113 long,
114 default_value_t = 32,
115 help = "Size of the Move contents of the NFT to be minted, in bytes.\
116 Defaults to 32 bytes (i.e., NFT with ID only)."
117 )]
118 nft_size: u16,
119 #[arg(
120 long,
121 help = "If true, call a single batch_mint Move function.\
122 Otherwise, batch via a PTB with multiple commands"
123 )]
124 use_batch_mint: bool,
125 },
126 Publish {
127 #[arg(
128 long,
129 help = "Path to the manifest file that describe the package dependencies.\
130 Follow examples in the tests directory to see how to set up the manifest file.\
131 The manifest file is a json file that contains a list of dependent packages that need to\
132 be published first, as well as the root package that will be benchmarked on. Each package\
133 can be either in source code or bytecode form. If it is in source code form, the benchmark\
134 will compile the package first before publishing it."
135 )]
136 manifest_file: PathBuf,
137 },
138}
139
140impl WorkloadKind {
141 pub(crate) fn gas_object_num_per_account(&self) -> u64 {
142 match self {
143 WorkloadKind::PTB { num_transfers, .. } => *num_transfers + 1,
145 WorkloadKind::Publish { .. } => 1,
146 }
147 }
148}