Actually I suppose normalizing by calls to integrand does answer your point 
about implementations*, *just about algorithm. Its true, when I look at the 
ProfileView (attached) it does seem like most of the time is actually spent 
inside quadgk. In fact, most of it is inside the jl_apply_generic function. 
I don't know enough about Julia to know what that function does. Could that 
be a sign there's something non-optimal going on? (To profile this I am 
doing @profile for _=1:10000; test.f(1.); end to get enough samples, is 
that correct?) 


Marius




On Sunday, June 19, 2016 at 4:41:47 PM UTC+2, Marius Millea wrote:
>
> They *are* different algorithms, but when I was comparing speeds with the 
> other codes, I compared it in terms of time per number of calls of the 
> inner integrand function. So basically I'm testing the speed of the 
> integrand functions themselves, as well as the speed of the integration 
> library code, as well as any function call overhead type thing. With this 
> metric, the Julia code was close, but it was the slowest (although of 
> course far more succinct and easy to read). 
>
>
> On Saturday, June 18, 2016 at 7:46:35 PM UTC+2, Gabriel Gellner wrote:
>>
>> What integration library are you using with Cython/Fortran? Is it using 
>> the same algorithm as quadgk? Your code seems so simple I imagine this is 
>> just comparing the quadrature implementations :)
>>
>> On Saturday, June 18, 2016 at 5:53:57 AM UTC-7, Marius Millea wrote:
>>>
>>> Hi all, I'm sort of just starting out with Julia, I'm trying to get 
>>> gauge of how fast I can make some code of which I have Cython and Fortran 
>>> versions to see if I should continue down the path of converting more or my 
>>> stuff to Julia (which in general I'd very much like to, if I can get it 
>>> fast enough). I thought maybe I'd post the code in question here to see if 
>>> I could get any tips. I've stripped down the original thing to what I think 
>>> are the important parts, a nested integration with an inner function 
>>> closure and some global variables. 
>>>
>>> module test
>>>
>>> const a = 1.
>>>
>>> function f(x)
>>>     quadgk(y->1/g(y),0,x)[1]  # <=== outer integral
>>> end
>>>
>>> function g(y)
>>>     integrand(x) = x^2*sqrt(x^2*y^2+a)/(exp(sqrt(x^2+y^2))+a)
>>>     quadgk(integrand,0,Inf)[1]   # <=== inner integral
>>> end
>>>
>>> end
>>>
>>>
>>> > @timeit test.f(1.)
>>> 100 loops, best of 3: 3.10 ms per loop
>>>
>>>
>>>
>>>
>>> Does anyone have any tips that squeezes a little more out of this code? 
>>> I have run ProfileView on it, and although I'm not sure I fully understand 
>>> how to read its output, I think it's saying the majority of runtime is 
>>> spent in quadgk itself. So perhaps I should look into using a different 
>>> integration library? 
>>>
>>> Thanks for any help. 
>>>
>>>

Reply via email to