thanks Andriy for the information
i still put the whole list because somebody could have important comments.
i would have some other questions to understand better, if you don't mind :
suppose i have a program with something like
...
if (withToDoPlot1) {
TCanvas *mycanvas=new TCanvas(...)
TH1F *myhisto1=new TH1F(...)
"fill of myhisto1"
"draw of myhisto1"
}
and an another version, the same, but without pointer
i mean
if (...) {
TCanvas mycanvas(...)
TH1F myhisto(...)
...
...draw()
}
==>what will be the difference ?
B) performances :
i just made a dummy test of using or not using dynamical allocation,
the performance difference is huge : the dynamical is much more slower
example :
(in addition, in this example, i didn't do the "delete", which is
"forbidden", just to save a bit more time : even with that, dynamical
allocation is still very slow)
example :
1)the dynamic way :
0.309 second to run on a given computer
(i check that the differences of processing time is relevant with
regards to fluctuations)
#include <iostream>
int main()
{
class person
{
public :
int age;
};
for (int j=0;j<1000;j++) {
for (int i=0;i<100000;i++) { class person *marc=new person(); marc->age=33; // std::cout << "age de marc=" << marc->age << std::endl; } // delete person; (notice i don't delete to save time, but i don'thave the "right"
}
}
2)the static way (actually, i'm not sure that "static" is the good word
:
on the same computer :
6.3 second : much more slower !!!
#include <iostream>
int main()
{
class person
{
public :
int age;
};
for (int j=0;j<1000;j++) {
for (int i=0;i<100000;i++) { class person *marc=new person(); marc->age=33; // std::cout << "age de marc=" << marc->age << std::endl; } // delete person;
regards
On Sat, 23 Jan 2010, Andriy Zatserklyaniy wrote:
> Hi Mark,
>
>
>
>
>
>
>
>
> >> Hello, >> >> i'm using a basic root program (.C) that allows to make some histograms of >> variables of a given ntuple (a .root file) >> >> Up to now, i created the histogram dynamically with >> TH1F *myhisto=new TH1F(...) >> >> i was wondering what it the more optimal (in terms of memory, cpu usage, or >> any other criterious you know better than me) way to do ? : >> >> *this kind of dynamical allocation >> >> or >> >> *a non dynamical allocation >> (i mean : >> TH1F myhisto(...) >> ) >> >> (just in case : i do always the same plots and there variables are always >> in the ntuple) >> >> thanks ! >> >> (i'll reply in private to answers to prevent spamming you all) >> >> >Received on Sat Jan 23 2010 - 22:40:40 CET
This archive was generated by hypermail 2.2.0 : Sun Jan 24 2010 - 05:50:02 CET