Skip to content

Commit

Permalink
IPA bench: log random seed and runtime at info level
Browse files Browse the repository at this point in the history
  • Loading branch information
andyleiserson committed Apr 11, 2024
1 parent 4dc9e60 commit 8c1f45e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 11 additions & 3 deletions ipa-core/benches/oneshot/ipa.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{
env,
num::{NonZeroU32, NonZeroU64, NonZeroUsize},
time::Instant,
};
Expand Down Expand Up @@ -102,9 +103,11 @@ async fn run(args: Args) -> Result<(), Error> {
gateway_config: GatewayConfig::new(args.active()),
..TestWorldConfig::default()
};
// Construct TestWorld early to initialize logging.
let world = TestWorld::new_with(&config);

let seed = args.random_seed.unwrap_or_else(|| random());
tracing::trace!(
tracing::info!(
"Using random seed: {seed} for {q} records",
q = args.query_size
);
Expand Down Expand Up @@ -154,12 +157,11 @@ async fn run(args: Args) -> Result<(), Error> {
&order,
);

let world = TestWorld::new_with(config.clone());
tracing::trace!("Preparation complete in {:?}", _prep_time.elapsed());

let _protocol_time = Instant::now();
test_oprf_ipa::<BenchField>(&world, raw_data, &expected_results, args.config()).await;
tracing::trace!(
tracing::info!(
"{m:?} IPA for {q} records took {t:?}",
m = args.mode,
q = args.query_size,
Expand All @@ -172,6 +174,12 @@ fn main() -> Result<(), Error> {
#[cfg(feature = "dhat-heap")]
let _profiler = dhat::Profiler::new_heap();

// The default in test_fixture::logging is to enable logging for ipa-core only. Override that to
// include logs from the bench as well.
if env::var_os("RUST_LOG").is_none() {
env::set_var("RUST_LOG", format!("{}=INFO,{}=INFO", ipa_core::CRATE_NAME, env!("CARGO_CRATE_NAME")));
}

let args = Args::parse();
let rt = Builder::new_multi_thread()
.worker_threads(args.threads)
Expand Down
2 changes: 2 additions & 0 deletions ipa-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ pub(crate) mod test_executor {
}
}

pub const CRATE_NAME: &'static str = env!("CARGO_CRATE_NAME");

#[macro_export]
macro_rules! const_assert {
($x:expr $(,)?) => {
Expand Down

0 comments on commit 8c1f45e

Please sign in to comment.