peter-toth commented on PR #7942:
URL: 
https://github.com/apache/arrow-datafusion/pull/7942#issuecomment-1864247136

   I wrote a small benchmark test:
   ```rust
       #[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()
           );
   
           println!("results: {}", and_tree == and_tree_clone);
   
           let now = Instant::now();
           and_tree = and_tree
               .transform_down_old(&mut |e| match e {
                   Expr::Literal(_) => Ok(Transformed::Yes(lit(false))),
                   o => Ok(Transformed::No(o)),
               })
               .unwrap();
           println!(
               "and_tree.transform_down_old 2: {}",
               now.elapsed().as_millis()
           );
   
           let now = Instant::now();
           and_tree_clone
               .transform_down(&mut |e| match e {
                   Expr::Literal(_) => {
                       *e = lit(false);
                       Ok(TreeNodeRecursion::Continue)
                   }
                   o => Ok(TreeNodeRecursion::Continue),
               })
               .unwrap();
           println!(
               "and_tree_clone.transform_down 2: {}",
               now.elapsed().as_millis()
           );
   
           println!("results: {}", and_tree == and_tree_clone);
       }
   }
   ```
   available here: 
https://github.com/peter-toth/arrow-datafusion/commits/refactor-treenode-benchmark/
 and run it with `--release` as `cargo test --color=always --lib 
tree_node::expr::test::transform_test --release -- --show-output` and this is 
what I got :
   ```
   ---- tree_node::expr::test::transform_test stdout ----
   create_and_tree: 8912
   and_tree.transform_down_old: 6129
   and_tree.clone: 12670
   and_tree_clone.transform_down: 2137
   results: true
   and_tree.transform_down_old 2: 6507
   and_tree_clone.transform_down 2: 2734
   results: true
   ```
   
   So `transform_down()` seems to be 2.5-3x times faster than 
`transform_down_old()`.
   The above results already contain @sadboy's 
https://github.com/apache/arrow-datafusion/pull/8591 improvement to the current 
code. I'm failry new to Datafusion and Rust so please let me know if you would 
suggest a different benchmark.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to