-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
352 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,49 @@ | ||
//! Benchmarking for syncing functions | ||
use crate::tracing::Instrument; | ||
use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; | ||
use tokio::runtime::{Builder, Runtime}; | ||
use xmtp_mls::utils::bench::{bench_async_setup, BENCH_ROOT_SPAN}; | ||
use xmtp_mls::utils::bench::{clients, init_logging}; | ||
// //! Benchmarking for syncing functions | ||
// use crate::tracing::Instrument; | ||
// use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; | ||
// use tokio::runtime::{Builder, Runtime}; | ||
// use xmtp_mls::utils::bench::{bench_async_setup, BENCH_ROOT_SPAN}; | ||
// use xmtp_mls::utils::bench::{clients, init_logging}; | ||
// | ||
// #[macro_use] | ||
// extern crate tracing; | ||
// | ||
// fn setup() -> Runtime { | ||
// Builder::new_multi_thread() | ||
// .enable_time() | ||
// .enable_io() | ||
// .thread_name("xmtp-bencher") | ||
// .build() | ||
// .unwrap() | ||
// } | ||
// | ||
// fn start_sync_worker(c: &mut Criterion) { | ||
// init_logging(); | ||
// | ||
// let runtime = setup(); | ||
// let mut benchmark_group = c.benchmark_group("start_sync_worker"); | ||
// benchmark_group.sample_size(10); | ||
// benchmark_group.bench_function("start_sync_worker", |b| { | ||
// let span = trace_span!(BENCH_ROOT_SPAN); | ||
// b.to_async(&runtime).iter_batched( | ||
// || { | ||
// bench_async_setup(|| async { | ||
// let client = clients::new_client(true).await; | ||
// // set history sync URL | ||
// (client, span.clone()) | ||
// }) | ||
// }, | ||
// |(client, span)| async move { client.start_sync_worker().instrument(span) }, | ||
// BatchSize::SmallInput, | ||
// ) | ||
// }); | ||
// | ||
// benchmark_group.finish(); | ||
// } | ||
|
||
#[macro_use] | ||
extern crate tracing; | ||
|
||
fn setup() -> Runtime { | ||
Builder::new_multi_thread() | ||
.enable_time() | ||
.enable_io() | ||
.thread_name("xmtp-bencher") | ||
.build() | ||
.unwrap() | ||
} | ||
|
||
fn start_sync_worker(c: &mut Criterion) { | ||
init_logging(); | ||
|
||
let runtime = setup(); | ||
let mut benchmark_group = c.benchmark_group("start_sync_worker"); | ||
benchmark_group.sample_size(10); | ||
benchmark_group.bench_function("start_sync_worker", |b| { | ||
let span = trace_span!(BENCH_ROOT_SPAN); | ||
b.to_async(&runtime).iter_batched( | ||
|| { | ||
bench_async_setup(|| async { | ||
let client = clients::new_client(true).await; | ||
// set history sync URL | ||
(client, span.clone()) | ||
}) | ||
}, | ||
|(client, span)| async move { | ||
client | ||
.start_sync_worker() | ||
.instrument(span) | ||
.await | ||
.unwrap() | ||
}, | ||
BatchSize::SmallInput, | ||
) | ||
}); | ||
|
||
benchmark_group.finish(); | ||
} | ||
|
||
criterion_group!( | ||
name = sync; | ||
config = Criterion::default().sample_size(10); | ||
targets = start_sync_worker | ||
); | ||
criterion_main!(sync); | ||
// criterion_group!( | ||
// name = sync; | ||
// config = Criterion::default().sample_size(10); | ||
// targets = start_sync_worker | ||
// ); | ||
// criterion_main!(sync); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.