Re: TH1 and Fill

From: Marc Escalier <escalier_at_lal.in2p3.fr>
Date: Sat, 24 Apr 2010 10:00:38 +0200


thanks John and Rene,

i will try to make the minimum code that reproduces the phenomena and will send you

thank you


On Fri, 23 Apr 2010, John Idarraga wrote:

> Hello Marc,
>
> Ok, here's the part that is hard to answer without looking at your
> code ... when you say
>
> " ... i see that about 90 % of the time consuming is in the Fill part of
> the program ... "
>
> it means exactly the Fill(...) call ? ... or by "part of the program"
> you mean a context or a few instructions ?
>
> I think, really, the way to go would be to examine your problem
> instruction by instruction. I don't know of any tricks to speed up the
> Fill(...) call apart from not making the argument of Fill a too complex
> calculation. The Fill should not be taking too much time. So, what I
> am going to do is to show you how to track down your code instruction by
> instruction by 'profiling' your code. Here's a nice exercise. (if you
> already know this, I apologize, I will asume you have not done profiling
> with valgrind before)
>
> I will use ROOT as an API, meaning that I will provide the main() part
> of the program. Consider the following code
>
> #include <TROOT.h>
> #include <TH1F.h>
>
> #include <iostream>
>
> using namespace std;
>
> int main(){
>
> TH1F * h1 = new TH1F("h1","h1",100,-3.,3.);
>
> h1->FillRandom("gaus",1000);
>
> cout << "[DONE]" << endl;
>
> return 0;
> }
>
> you can compile like this
>
> g++ histoTest.cpp -g3 -W -Wall -o histoTest `$ROOTSYS/bin/root-config
> --libs` `$ROOTSYS/bin/root-config --cflags`
>
> test it
>
> ./histoTest
>
> now let's profile. Run it like this
>
> valgrind --tool=callgrind ./histoTest
>
> it will run quite slow ... valgrind is some sort of virtual machine,
> patience. At the end you will get a file called
>
> callgrind.out.XXXX
>
> where XXXX is the pid ... you can open it with
>
> kcachegrind callgrind.out.XXXX
>
> magic's here ;) ! .... In the search box look for "FillRandom", and at
> the right side select the "callee map" ... you will see what's going on
> by yourself. FillRandom() is calling Fill() at some point. Check how
> much time the Fill() function takes ... not much, almost negligible in
> fact. Fill() is really not very heavy. That's why I tend to think
in
> your code Fill() is not the issue.
>
> let me know if this helps
>
> cheers !
>
> John Idarraga
>
> On Fri, 2010-04-23 at 23:11 +0200, Marc Escalier wrote:
>>
>> i use a TBenchmark to see the time "global", and the time for the
>> "filling of the histogram", and i see that about 90 % of the time
>> consuming is in the Fill part of the program
>
>
Received on Sat Apr 24 2010 - 10:00:45 CEST

This archive was generated by hypermail 2.2.0 : Mon Apr 26 2010 - 11:50:01 CEST