test: add a/b test checker

This commit is contained in:
ThetaDev 2022-11-05 19:53:36 +01:00
parent 68342cecab
commit d3aacc77aa
3 changed files with 134 additions and 0 deletions

View file

@ -1,3 +1,4 @@
mod abtest;
mod collect_album_types;
mod collect_large_numbers;
mod collect_playlist_dates;
@ -31,6 +32,12 @@ enum Commands {
GenLocales,
GenDict,
DownloadTestfiles,
AbTest {
#[clap(value_parser)]
id: Option<u16>,
#[clap(short, default_value = "100")]
n: usize,
},
}
#[tokio::main]
@ -62,5 +69,18 @@ async fn main() {
Commands::DownloadTestfiles => {
download_testfiles::download_testfiles(&cli.project_root).await
}
Commands::AbTest { id, n } => {
match id {
Some(id) => {
let ab = abtest::ABTest::try_from(id).expect("invalid A/B test id");
let res = abtest::run_test(ab, n, cli.concurrency).await;
eprintln!("{} occurences", res);
}
None => {
let res = abtest::run_all_tests(n, cli.concurrency).await;
println!("{}", serde_json::to_string(&res).unwrap())
}
};
}
};
}