Skip to content

Commit

Permalink
benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-toth committed Dec 20, 2023
1 parent cc15a71 commit b3b282b
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions datafusion/expr/src/tree_node/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,3 +480,37 @@ where
}
Ok(v)
}

#[cfg(test)]
mod test {
use std::time::Instant;
use datafusion_common::tree_node::{Transformed, TreeNode, TreeNodeRecursion};
use crate::{lit, Expr, and};

fn create_and_tree(level: u32) -> Expr {
if level == 0 {
lit(true)
} else {
and(create_and_tree(level - 1), create_and_tree(level - 1))
}
}

#[test]
fn transform_test() {
let now = Instant::now();
let mut and_tree = create_and_tree(25);
println!("create_and_tree: {}", now.elapsed().as_millis());

let now = Instant::now();
and_tree = and_tree.transform_down_old(&mut |e| Ok(Transformed::No(e))).unwrap();
println!("and_tree.transform_down_old: {}", now.elapsed().as_millis());

let now = Instant::now();
let mut and_tree_clone = and_tree.clone();
println!("and_tree.clone: {}", now.elapsed().as_millis());

let now = Instant::now();
and_tree_clone.transform_down(&mut |e| Ok(TreeNodeRecursion::Continue)).unwrap();
println!("and_tree_clone.transform_down: {}", now.elapsed().as_millis());
}
}

0 comments on commit b3b282b

Please sign in to comment.