It's great that you're pursuing this. I confess I don't know the internal details of anonymous function creation to be able to advise you on what may be happening. Can you please file this information as an issue? (It's nicely detailed already.)
The only other thing I can suggest is that, if you're running 0.4, try FastAnonymous (be sure to check the 0.4 README). But that package is currently broken due to the tuple overhaul. If you're impatient, you could check out a version of julia from before merger of https://github.com/JuliaLang/julia/pull/10380 Or, I might get around to updating FastAnonymous by this weekend. Best, --Tim On Friday, May 01, 2015 07:46:29 AM 'Antoine Messager' via julia-users wrote: > I am sorry for insisting, but it seems that even with anonymous function, > the time necessary to create an anonymous function or a normal function > (without the @gensym) is linearly increasing with the quantity of function > created. I have tried the following: > > *for i in 1:1000* > * if(i%100==0)* > * print("$(int(i/10))%")* > * end* > * tic()* > * > mymat=sgenerateAdjMat(Nnodes,int(Nnodes*1.5),int(Nnodes*0.3),2);* > * > degrates=exp((rand(Distributions.Uniform(-3.0*log(10),2.0*log(10)),Nnodes)) > );* * > basalrates=exp((rand(Distributions.Uniform(-3.0*log(10),2.0*log(10)),Nnodes > )));* * > lhs,rhs,lhsjac,rhsjac=make_funjac_ode(mymat,Nnodes,degrates,basalrates,prob > act);* * myfun=make_anonymous_f(lhs,rhs);* > * time[i]=toq()* > *end* > > <https://lh3.googleusercontent.com/-tyrafotpY98/VUOQKo4IWNI/AAAAAAAAAB0/sDbw > nXDvIik/s1600/Capture%2Bd%E2%80%99e%CC%81cran%2B2015-05-01%2Ba%CC%80%2B15.38 > .03.png> It the the same with the normal function. > > I know that the creation of the parameters (rhs,lhs...) always takes the > same amount of time. > Anonymous function: I need to eval the following: > *function code_anonymous_f(lhs::Dict, rhs::Dict)* > * lines = {}* > * for key in keys(lhs)* > * push!(lines, :( $(lhs[key]) = $(rhs[key])) )* > * end* > * quote* > * func = (y, fy) -> begin* > * $(lines...)* > * end* > * end* > *end* > > Normal function @gensym expressed only once: > *@gensym f!* > *function code_f(lhs::Dict, rhs::Dict)* > * lines = {}* > * for key in keys(lhs)* > * push!(lines, :( $(lhs[key]) = $(rhs[key])) )* > * end* > * quote* > * function $f!(y, fy)* > * $(lines...)* > * end* > * end* > *end* > > I would need to create around 1.000.000 systems so I don't know what to do. > After 20.000 tryes, it takes like 17 second instead of 0.01 at the > beginning. I don't understand where it could come from. > > Thank you in advance, > Antoine > > Le lundi 27 avril 2015 15:49:56 UTC+1, Antoine Messager a écrit : > > 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
