Skip to content

Commit 80a3f42

Browse files
committed
Add --repeat to examples
1 parent 0b2ded1 commit 80a3f42

File tree

16 files changed

+168
-30
lines changed

16 files changed

+168
-30
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ thiserror = "2.0.3"
7575
transpose = "0.2.2"
7676
tracing = "0.1.38"
7777
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "fmt"] }
78-
tracing-profile = "0.10.9"
78+
tracing-profile = { git = "https://github.com/IrreducibleOSS/tracing-profile.git", branch = "fkondej/eng2-260-trace-filename-builder" }
7979
trait-set = "0.3.0"
8080
z3 = "0.13.3"
8181

crates/examples/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,10 @@ impl ExampleCircuit for MyCircuitExample {
113113
}
114114

115115
fn main() -> Result<()> {
116-
let _tracing_guard = tracing_profile::init_tracing()?;
117-
118116
// Create and run the CLI - this is all you need!
119117
Cli::<MyCircuitExample>::new("my_circuit")
120118
.about("Description of what your circuit does")
119+
.with_repeat() // Optional: Enable --repeat flag to run multiple iterations
121120
.run()
122121
}
123122
```
@@ -272,6 +271,12 @@ cargo run --release --example my_circuit -- --help
272271

273272
# Run with increased verbosity
274273
RUST_LOG=info cargo run --release --example my_circuit
274+
275+
# Run multiple iterations (useful for benchmarking, testing consistency, etc.)
276+
cargo run --release --example my_circuit -- --repeat 3
277+
278+
# With perfetto feature, each iteration creates a separate trace file
279+
cargo run --release --example my_circuit --features perfetto -- --repeat 3
275280
```
276281

277282
## CLI subcommands

crates/examples/examples/blake2s.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ struct Blake2sExample {
1414
}
1515

1616
/// Circuit parameters that affect structure (compile-time configuration)
17-
#[derive(Args, Debug)]
17+
#[derive(Args, Debug, Clone)]
1818
struct Params {
1919
/// Maximum message length in bytes that the circuit can handle.
2020
#[arg(long, default_value_t = 128)]
2121
max_bytes: usize,
2222
}
2323

2424
/// Instance data for witness population (runtime values)
25-
#[derive(Args, Debug)]
25+
#[derive(Args, Debug, Clone)]
2626
#[group(multiple = false)]
2727
struct Instance {
2828
/// Length of the randomly generated message, in bytes (defaults to half of --max-message-len).
@@ -85,11 +85,9 @@ impl ExampleCircuit for Blake2sExample {
8585
}
8686

8787
fn main() -> Result<()> {
88-
let _tracing_guard = tracing_profile::init_tracing()?;
89-
90-
// Create and run the CLI
9188
Cli::<Blake2sExample>::new("blake2s")
9289
.about("Blake2s hash function circuit example")
90+
.with_repeat()
9391
.long_about(
9492
"Blake2s cryptographic hash function circuit implementation.\n\
9593
\n\

crates/examples/examples/ethsign.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use anyhow::Result;
22
use binius_examples::{Cli, circuits::ethsign::EthSignExample};
33

44
fn main() -> Result<()> {
5-
let _tracing_guard = tracing_profile::init_tracing()?;
6-
75
Cli::<EthSignExample>::new("ethsign")
86
.about("Ethereum-style signing example")
7+
.with_repeat()
98
.run()
109
}

crates/examples/examples/hash_based_sig.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct HashBasedSigExample {
2929
hashers: XmssMultisigHashers,
3030
}
3131

32-
#[derive(Args, Debug)]
32+
#[derive(Args, Debug, Clone)]
3333
struct Params {
3434
/// Number of validators in the multi-signature
3535
#[arg(short = 'n', long, default_value_t = 3)]
@@ -44,7 +44,7 @@ struct Params {
4444
spec: u8,
4545
}
4646

47-
#[derive(Args, Debug)]
47+
#[derive(Args, Debug, Clone)]
4848
struct Instance {}
4949

5050
impl ExampleCircuit for HashBasedSigExample {
@@ -193,12 +193,15 @@ impl ExampleCircuit for HashBasedSigExample {
193193

194194
Ok(())
195195
}
196+
197+
fn param_summary(params: &Self::Params) -> Option<String> {
198+
Some(format!("{}v-{}t-s{}", params.num_validators, params.tree_height, params.spec))
199+
}
196200
}
197201

198202
fn main() -> Result<()> {
199-
let _tracing_guard = tracing_profile::init_tracing()?;
200-
201203
Cli::<HashBasedSigExample>::new("hash_based_sig")
202204
.about("Hash-based multi-signature (XMSS) verification example")
205+
.with_repeat()
203206
.run()
204207
}

crates/examples/examples/keccak.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use anyhow::Result;
22
use binius_examples::{Cli, circuits::keccak::KeccakExample};
33

44
fn main() -> Result<()> {
5-
let _tracing_guard = tracing_profile::init_tracing()?;
6-
75
Cli::<KeccakExample>::new("keccak")
86
.about("Keccak-f[1600] permutation example - chains multiple permutations together")
7+
.with_repeat()
98
.run()
109
}

crates/examples/examples/sha256.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use anyhow::Result;
22
use binius_examples::{Cli, circuits::sha256::Sha256Example};
33

44
fn main() -> Result<()> {
5-
let _tracing_guard = tracing_profile::init_tracing()?;
6-
75
Cli::<Sha256Example>::new("sha256")
86
.about("SHA256 compression function example")
7+
.with_repeat()
98
.run()
109
}

crates/examples/examples/sha512.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use anyhow::Result;
22
use binius_examples::{Cli, circuits::sha512::Sha512Example};
33

44
fn main() -> Result<()> {
5-
let _tracing_guard = tracing_profile::init_tracing()?;
6-
75
Cli::<Sha512Example>::new("sha512")
86
.about("SHA512 compression function example")
7+
.with_repeat()
98
.run()
109
}

crates/examples/examples/zklogin.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use anyhow::Result;
22
use binius_examples::{Cli, circuits::zklogin::ZkLoginExample};
33

44
fn main() -> Result<()> {
5-
let _tracing_guard = tracing_profile::init_tracing()?;
6-
75
Cli::<ZkLoginExample>::new("zklogin")
86
.about("Circuit verifying knowledge of a valid OpenID Connect login")
7+
.with_repeat()
98
.run()
109
}

crates/examples/src/circuits/blake2s.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,8 @@ impl ExampleCircuit for Blake2sExample {
5959

6060
Ok(())
6161
}
62+
63+
fn param_summary(params: &Self::Params) -> Option<String> {
64+
Some(format!("{}b", params.max_bytes))
65+
}
6266
}

0 commit comments

Comments
 (0)