time travel bench size

main
Ziyang Hu 2 years ago
parent cabd00df3d
commit 7a89ecbc3c

@ -133,7 +133,19 @@ fn single_tt_read(k: usize) {
TEST_DB
.run_script(
&format!(r#"
?[min_cost(pack)] := *tt{}{{k: $id, vld, v}}, pack = [v, vld]
?[smallest_by(pack)] := *tt{}{{k: $id, vld, v}}, pack = [v, vld]
"#, k),
BTreeMap::from([("id".to_string(), json!(i))]),
)
.unwrap();
}
fn single_tt_travel_read(k: usize) {
let i = rand::thread_rng().gen_range(0..10000);
TEST_DB
.run_script(
&format!(r#"
?[v] := *tt{}{{k: $id v @ "NOW"}}
"#, k),
BTreeMap::from([("id".to_string(), json!(i))]),
)
@ -160,4 +172,14 @@ fn time_travel_init(_: &mut Bencher) {
dbg!(k);
dbg!((count as f64) / qps_single_tt_time.elapsed().as_secs_f64());
}
for k in [1, 10, 100, 1000] {
let count = 100_000;
let qps_single_tt_travel_time = Instant::now();
(0..count).into_par_iter().for_each(|_| {
single_tt_travel_read(k);
});
dbg!(k);
dbg!((count as f64) / qps_single_tt_travel_time.elapsed().as_secs_f64());
}
}

@ -756,6 +756,47 @@ impl NormalAggrObj for AggrLatestBy {
}
}
define_aggr!(AGGR_SMALLEST_BY, false);
pub(crate) struct AggrSmallestBy {
found: DataValue,
cost: DataValue,
}
impl Default for AggrSmallestBy {
fn default() -> Self {
Self {
found: DataValue::Null,
cost: DataValue::Null,
}
}
}
impl NormalAggrObj for AggrSmallestBy {
fn set(&mut self, value: &DataValue) -> Result<()> {
match value {
DataValue::List(l) => {
ensure!(
l.len() == 2,
"'smallest_by' requires a list of exactly two items as argument"
);
let c = &l[1];
if *c < self.cost {
self.cost = c.clone();
self.found = l[0].clone();
}
Ok(())
}
v => bail!("cannot compute 'smallest_by' on {:?}", v),
}
}
fn get(&self) -> Result<DataValue> {
Ok(self.found.clone())
}
}
define_aggr!(AGGR_MIN_COST, true);
pub(crate) struct AggrMinCost {
@ -1188,6 +1229,7 @@ impl Aggregation {
name if name == AGGR_SHORTEST.name => Box::new(AggrShortest::default()),
name if name == AGGR_MIN_COST.name => Box::new(AggrMinCost::default()),
name if name == AGGR_LATEST_BY.name => Box::new(AggrLatestBy::default()),
name if name == AGGR_SMALLEST_BY.name => Box::new(AggrSmallestBy::default()),
name if name == AGGR_CHOICE_RAND.name => Box::new(AggrChoiceRand::default()),
name if name == AGGR_COLLECT.name => Box::new({
if args.is_empty() {

Loading…
Cancel
Save