The times for Julia code in my previous email are wrong, I wanted to write:
0.000126 seconds
0.004695 seconds (99.49 k allocations: 1.518 MB)
0.000871 seconds

On Sun, Nov 8, 2015 at 10:19 PM Cristóvão Duarte Sousa <cris...@gmail.com>
wrote:

> I agree, in fact my knowledge about branch prediction mechanisms is rather
> limited.
> But doing *if(rand()%2)* instead of *if(i%i)* yields times close to the
> given one. On the other hand, with a single type (with *if(true)*) the
> times drop to around 320 μs.
>
> For julia code, randomness seems to have higher impact:
> 0.000103 seconds
> 0.002179 seconds
> 0.000915 seconds
> (again, these times highly variable)
>
> Anyway, I updated the codes to choose the type randomly.
>
> On Sun, Nov 8, 2015 at 3:44 AM Stefan Karpinski <ste...@karpinski.org>
> wrote:
>
>> Yeah, that's a good point.
>>
>> On Saturday, November 7, 2015, Gustavo Goretkin <
>> gustavo.goret...@gmail.com> wrote:
>>
>>> 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" <cris...@gmail.com>
>>> 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