Time of TNode::Clone() + TNode::GetListOfNodes()->Add()

Alexander Zvyagin (zvyagin@mx.ihep.su)
Thu, 19 Feb 1998 15:43:48 GMT+03:00


IHEP, Protvino, Russia, 19-FEB-1998

Dear all!

I try to create geometry as described in
http://root.cern.ch/root/roottalk/roottalk97/1058.html

The macro:

// File b.C
void b(UInt_t N)
{
if( N==0 ) N=1;

gROOT->Reset();
g1 = new TGeometry ("Tempory","Tempory geometry");

new TBRIK("MAIN","This is main frame","void",10,10,10);
main_node = new TNode("MAINnode","This is main node","MAIN");
main_node->BuildListOfNodes();
main_node->cd();

new TBRIK("A","A","void",1,1,1);
Anode = new TNode("Anode","Anode","A");

TStopwatch timer;
timer.Start();

for( int i=0; i<N; i++ )
{
TNode *node = (TNode*) Anode->Clone();
if( NULL==node )
{
printf("Can not create node.\n");
exit(1);
}
main_node->GetListOfNodes()->Add(node);
//node->SetName("");
//node->SetPosition(0,0,0);
}

timer.Stop();
printf("N=%d rate = %g seconds per node\n",N,timer.CpuTime()/N);

return;
}

The root session:

*******************************************
* *
* W E L C O M E to R O O T *
* *
* Version 1.03/09 16 December 1997 *
* *
* You are welcome to visit our Web site *
* http://root.cern.ch *
* *
*******************************************

CINT/ROOT C/C++ Interpreter version 5.13.36, Nov 30 1997
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] .x b.C(1)
N=1 rate = 0.01 seconds per node
NULL
root [1] .x b.C(5)
N=5 rate = 0.004 seconds per node
NULL
root [2] .x b.C(7)
N=7 rate = 0.0114286 seconds per node
NULL
root [3] .x b.C(8)
N=8 rate = 0.02375 seconds per node
NULL
root [4] .x b.C(9)
N=9 rate = 0.0544444 seconds per node
NULL
root [5] .x b.C(10)
N=10 rate = 0.146 seconds per node
NULL
root [6] .x b.C(11)
N=11 rate = 0.515455 seconds per node
NULL
root [7] .x b.C(12)
N=12 rate = 2.37 seconds per node
NULL
root [8] .x b.C(13)
N=13 rate = 10.4562 seconds per node
NULL
root [9] .x b.C(14)
N=14 rate = 41.3914 seconds per node
NULL

The call time of TNode::Clone() strongly depends on number of
TNode::GetListOfNodes()->Add() calls. It is almost impossible to have hundreds
of TNodes with the aid of TNode::GetListOfNodes()->Add() function!

Did I something wrong?
Alexander Zvyagin.