I just played around with using time_ns() from the Julia and C code and 
didn't observe significant differences in the timing. I don't think the 
issue is just timing accuracy, because then the results are very consistent 
without too much variation between runs.

On Tuesday, January 27, 2015 at 5:46:46 PM UTC-5, Jacob Quinn wrote:
>
> I'm not sure about using the `time()` function in the julia code. I 
> believe it's resolution is system dependent, but microseconds at best. I 
> think it's more common to use the `tic()` and `toq()` that use `time_ns()` 
> internally for nanosecond resolution. Though you probably did that for 
> easier C compatibility. Not sure though.
>
> On Tue, Jan 27, 2015 at 3:39 PM, Miles Lubin <[email protected] 
> <javascript:>> wrote:
>
>> I'm working on a microbenchmark and found a surprising result (maybe 
>> not?) that Julia is about 2x faster than the same algorithm hand-coded in 
>> C. I wanted to check if I'm doing anything obviously wrong here before 
>> reporting these results. The timings reproduce across different systems and 
>> compiler options (clang/gcc -O2/-O3).
>>
>> The test is just to compute square root using newton's method. The 
>> relevant code is in this gist: 
>> https://gist.github.com/mlubin/4994c65c7a2fa90a3c7e.
>>
>> On Julia 0.3.5, each function call takes 8.85*10^-8 seconds. The best 
>> timing I've seen from C is 1.61*10^-7 using gcc -O2 -march=native.
>>
>> I did my best to check for common mistakes:
>> - Julia and C use the exact same timing routine with 10,000 repetitions
>> - Both give the correct answer, and the important code isn't being 
>> optimized away.
>>
>> Any ideas as to why Julia is faster on this very simple code? I know that 
>> performance comparisons with runtimes on the order of nanoseconds are 
>> probably not too meaningful, but people still like absolute numbers, and 
>> it's a bit surprising that I can't match the performance of Julia from C.
>>
>> Thanks,
>> Miles
>>
>
>

Reply via email to