I think branch predictors on many platforms today use a table indexed on
the history of the last couple of branches, so the period-two cycle you
have is likely getting a lot of correct branch hits. If you mean to totally
defeat the branch prediction, I think you should use something
pseudorandom.
On Nov 6, 2015 12:27 PM, "Cristóvão Duarte Sousa" <[email protected]> wrote:

> Hi,
>
> I've been wondering how Julia dispatching system would compare to the C++
> virtual functions dispatch one.
> Hence, I write a simple test in both Julia and C++ that measures the
> calling of a function over the elements of both an array of concrete
> objects and another of abstract pointers to objects of derived types.
>
> Here is the code https://gist.github.com/cdsousa/f5d669fe3fba7cf848d8 .
>
> The usual timings for C++ in my machine, for the concrete and the abstract
> arrays respectively, are around
> 0.000143 seconds
> 0.000725 seconds
>
> For the Julia code the timings have much more variability, but they are
> around
> 0.000133 seconds
> 0.002414 seconds
>
> This shows that Julia (single) dispatch performance is not that bad while
> it has some room to improvement.
>
> If I'm doing something terribly wrong in these tests, please tell me :)
>
> PS: Thank you all, developers of Julia!
>
>
>

Reply via email to