I’m new with Root. I’m also dumb when it comes to C++, so I need some help, please
I would like to check time that root takes to perform some commands. I guess it is something like gRoot->GetTime() or gSystem->GetTime() (which one?), but before that some library needs to be loaded (does it?) and I have no idea which…
Can somebody give me a hint about that, please?

Hi Julia,
you want a TStopwatch. See e.g. $ROOTSYS/tutorials/testrandom.C

Thanx Axel,
I thought more about loading something in Root command line than adding it to the script. SOmething like gSystem->Load(herethe properlibraryIguess) and then before I run something in root I would perform this gSystem->GetTime() and after that something finishes root gives me time in secons it took to do it… Any ideas?


At the ROOT command line, do

then all subsequent commands will be timed (real and cpu time)


Hi Julia,

you can do
root [0] {TH1F h(“h”,“h”,10,0.,1.); TStopwatch sw; sw.Start(); h.FillRandom(“gaus”, 10000); std::cout<<sw.CpuTime();}

Here, TH1F::FillRandom is the command that’s being timed. You can also run a macro by using
root [0] {TStopwatch sw; sw.Start(); gROOT->ProcessLine(".x MyMacro.C"); std::cout<<sw.CpuTime();}