Filling histograms from a loop

HI ,
I have noticed that if I try to fill more than ~20 histograms from a for loop then it becomes very slow. For example:

for(int i=0;i<nentries;i++){
nu_reco->GetEntry(i);
hist1->Fill(var1);
hist2->Fill(var2);


}

Could this be b/c I am using an older root verion - 4.04.2b

                                              -thanks Debdatta.

Hi,

Are you running this code in the interpreter or in compiled code? Currently the interpreter has some subtle limit on the code size it can optimized (aka once a loop or function becomes too big, it is no longer optimized).

Cheers,
Philippe.