Skip to content

Commit

Permalink
Merge pull request #2465 from subspace/remove-single-audit-benchmark
Browse files Browse the repository at this point in the history
Hide single farmer benchmark behind disabled by default CLI option
  • Loading branch information
nazar-pc authored Jan 29, 2024
2 parents f1b7358 + 4c44d77 commit 5651388
Showing 1 changed file with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ pub(crate) enum BenchmarkArgs {
/// Number of samples to collect for benchmarking purposes
#[arg(long, default_value_t = 10)]
sample_size: usize,
/// Also run `single` benchmark (only useful for developers, not used by default)
#[arg(long)]
with_single: bool,
/// Disk farm to audit
///
/// Example:
Expand All @@ -37,6 +40,9 @@ pub(crate) enum BenchmarkArgs {
/// Number of samples to collect for benchmarking purposes
#[arg(long, default_value_t = 10)]
sample_size: usize,
/// Also run `single` benchmark (only useful for developers, not used by default)
#[arg(long)]
with_single: bool,
/// Disk farm to prove
///
/// Example:
Expand All @@ -55,19 +61,32 @@ pub(crate) fn benchmark(benchmark_args: BenchmarkArgs) -> anyhow::Result<()> {
match benchmark_args {
BenchmarkArgs::Audit {
sample_size,
with_single,
disk_farm,
filter,
} => audit(sample_size, disk_farm, filter),
} => audit(sample_size, with_single, disk_farm, filter),
BenchmarkArgs::Prove {
sample_size,
with_single,
disk_farm,
filter,
limit_sector_count,
} => prove(
sample_size,
with_single,
disk_farm,
filter,
limit_sector_count,
} => prove(sample_size, disk_farm, filter, limit_sector_count),
),
}
}

fn audit(sample_size: usize, disk_farm: PathBuf, filter: Option<String>) -> anyhow::Result<()> {
fn audit(
sample_size: usize,
with_single: bool,
disk_farm: PathBuf,
filter: Option<String>,
) -> anyhow::Result<()> {
let (single_disk_farm_info, disk_farm) = match SingleDiskFarm::collect_summary(disk_farm) {
SingleDiskFarmSummary::Found { info, directory } => (info, directory),
SingleDiskFarmSummary::NotFound { directory } => {
Expand Down Expand Up @@ -107,7 +126,7 @@ fn audit(sample_size: usize, disk_farm: PathBuf, filter: Option<String>) -> anyh
group.throughput(Throughput::Bytes(
sector_size as u64 * sectors_metadata.len() as u64,
));
{
if with_single {
let plot = OpenOptions::new()
.read(true)
.open(disk_farm.join(SingleDiskFarm::PLOT_FILE))
Expand Down Expand Up @@ -184,6 +203,7 @@ fn audit(sample_size: usize, disk_farm: PathBuf, filter: Option<String>) -> anyh

fn prove(
sample_size: usize,
with_single: bool,
disk_farm: PathBuf,
filter: Option<String>,
limit_sector_count: Option<usize>,
Expand Down Expand Up @@ -226,7 +246,7 @@ fn prove(
}
{
let mut group = criterion.benchmark_group("prove");
{
if with_single {
let plot = OpenOptions::new()
.read(true)
.open(disk_farm.join(SingleDiskFarm::PLOT_FILE))
Expand Down

0 comments on commit 5651388

Please sign in to comment.