Just a stab in the dark. If you're creating lots of non-conflicting
function names (i.e. all those functions are polluting your module), then
dispatch *may* take longer at each call? (someone with more knowledge of
the internals should chime in)
This code *seems* overly complex for what I think you're trying to do...
are you sure you can't just directly create an anonymous function?
On Monday, April 27, 2015 at 1:21:09 PM UTC-4, Antoine Messager wrote:
>
> I use meta programming to create my function. This is a simpler example.
> The parameters are generated randomly in the actual function.
>
> * lhs = {"ode1"=> :(fy[1]), "ode2"=> :(fy[2])};*
> * rhs = {"ode1"=> :(y[1]*y[1]-2.0), "ode2"=> :(y[2]-y[1]*y[1])};*
>
> * function code_f(lhs::Dict, rhs::Dict)*
> * lines = {}*
> * for key in keys(lhs)*
> * push!(lines, :( $(lhs[key]) = $(rhs[key])) )*
> * end*
> * @gensym f*
> * quote*
> * function $f(y, fy)*
> * $(lines...)*
> * end*
> * end*
> * end*
>
> Le lundi 27 avril 2015 18:12:24 UTC+1, Tom Breloff a écrit :
>>
>> Can you give us the definition of make_function as well? This is being
>> run in global scope?
>>
>> On Monday, April 27, 2015 at 12:37:48 PM UTC-4, Antoine Messager wrote:
>>>
>>> When I input the following code, where myfunction is only a system of 2
>>> equations with 2 unknowns, the code starts to be really slow after 10,000
>>> iterations. NLsolve is a non linear solver (
>>> https://github.com/EconForge/NLsolve.jl).
>>>
>>> * size=2*
>>> * for k in 1:100000*
>>> * myfun=make_function(size);*
>>> * try{*
>>> * res=nlsolve(myfun,rand(size))*
>>> * }*
>>> * end*
>>> * end*
>>>
>>> Thank you for your help,
>>> Antoine
>>>
>>> Le lundi 27 avril 2015 16:30:19 UTC+1, Mauro a écrit :
>>>>
>>>> It is a bit hard to tell what is going wrong with essentially no
>>>> information. Does the memory usage of Julia go up more than you would
>>>> expect from storing the results? Any difference between 0.3 and 0.4?
>>>> Anyway, you should try and make a small self-contained runable example
>>>> and post it otherwise it will be hard to divine an answer.
>>>>
>>>> On Mon, 2015-04-27 at 16:49, 'Antoine Messager' via julia-users <
>>>> [email protected]> wrote:
>>>> > Dear all,
>>>> >
>>>> > I need to create a lot of systems of equation, find some
>>>> characteristics of
>>>> > each system and store the system if of interest. Each system is
>>>> created
>>>> > under the same name. It works fine for the first 1000 systems but
>>>> after the
>>>> > program starts to be too slow. I have tried to use the garbage
>>>> collector
>>>> > each time I create a new system but it did not speed up the code. I
>>>> don't
>>>> > know what to do, I don't understand where it could come from.
>>>> >
>>>> > Cheers,
>>>> > Antoine
>>>>
>>>>