Type instabilities is often solved with the `const` keyword on some global 
variable.

I would try

const IdType = Int

Seems like Julia is not smart enough to guess that i::IdType will always 
ensure that i is a Int64 when IdType might change.

Regards Ivar

kl. 19:58:02 UTC+2 torsdag 18. september 2014 skrev G. Patrick Mauroy 
følgende:
>
> Ah ah, this is it, I found the culprit!
> Pre-declaring the type of my increment variables slowed down by a factor 
> of at least 2 if not 3 -- I will profile tonight when I can be on Linux, I 
> cannot now from Windows.
>
> i::IdType = zeroIdType # Slow increment in the loop
>
> i = zeroIdType # Much faster increment in the loop even through zeroIdType 
>> is of type IdType = Int = Int64.
>
> It smells more like explicitly typing the variables prevents the compiler 
> from using it as a registry or something like that.  I will let the experts 
> explain what really happens.
>
> By the way, in my endeavors, I got the impression the loop construct 
> for i in 1:n
> was slower than
> while i <=n
> But I need to run further tests to determine whether it is indeed so or 
> not.
>
>  
>
> On Thursday, September 18, 2014 1:44:58 PM UTC-4, G. Patrick Mauroy wrote:
>>
>> No change.
>> I over typed everything to avoid such type mismatches, particularly when 
>> experimenting with other integer types.  So unless I missed something 
>> somewhere, it should not be the case.
>> I suspect something like the compiler does not recognize the incrementing 
>> variables should be registries.  Unless it is the inherent speed of 
>> incrementing, but I doubt it, I had some faster runs at some points...
>>
>>>
>>>

Reply via email to