How to alias a function to have maximum speed

The problem is that g2 and g3 are variables in global scope. You either need to define them in the respective functions (test2 and test3), or declare them constant (const g2=f, const g3=rename()).

Also, to time your functions, consider using @btime from BenchmarkTools instead of @time, which includes the compilation time.

5 Likes