Recursion performance: why so slow?

Also because I was curious, how about Rust: ^.^

╰─➤  echo -n "\nElixir: "; elixir -e 'IO.puts(Tester.test())'; echo -n "\nGo: "; ./test_go; echo -n "\nOCaml: "; ./test_ml; echo -n "\n\nRust: "; ./test_rs; echo

Elixir: 6381.8058

Go: 12281.936

OCaml: 28238.0583

Rust: 18588

╰─➤  cat test.rs
use std::time::{Duration, SystemTime};

fn main() {
  let interval = Duration::from_secs(20);
  let start = SystemTime::now();
  let mut n = 0;
  while start.elapsed().unwrap() < interval {
    n += 1;
  }
  println!("{}", n / 20000);
}

And to take away from this just know that this is not telling how fast function calls are, but rather time getting functions are slow regardless of the language. I.E. use a real benchmarking tool, don’t count seconds because the only thing you are doing is benchmarking your time getting functions. :wink:

But hey, OCaml has the fastest time acquiring function! ^.^;