Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Any performance issues with multiple dispatch?

$
0
0

Hi!
I have some functions in a loop that get called a huge number of times. Some of them have two different forms, one when my elements are triangles and on when they are quads. Normally, I’d write two different for loops, check if I have quads or tris before entering the for loop, and then call the Tri function in one of them and the Quad in the other one. This would avoid an if condition to check which function to call for every loop iteration.
With multiple dispatch, I can have the same function written twice, once with 3 inputs and once with 4 inputs. No if statement, no two loops.
I haven’t seen a performance penalty from doing that, but maybe I’m not testing enough. Are there no performance disadvantages in doing what I described? Isn’t the code effectively performing an if statement to choose the right function?
Thanks a lot!

6 posts - 5 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Latest Images

Trending Articles



Latest Images