//----------- hrandom.C
#include "TStopwatch.h"
#include "TRandom2.h"
#include "TRandom3.h"
#include "TH1.h"
   
void hrandom()
{
   // example of a script computing the CPU time to fill an histogram
   // with 3 random number generators.
   
   const Int_t nfills = 10000000;
   TStopwatch timer;
   
   // create an histogram and evaluate the time to fill nfills time
   TH1F h("h","h",100,0,1);
   Int_t i;
   timer.Start();
   for (i=0;i<nfills;i++) h.Fill(0.5);
   Double_t fillTime = timer.CpuTime();
   printf("Time for Fill     = %f seconds\n",fillTime);


   //using TRandom
   timer.Start();
   TRandom r1;
   for (i=0;i<nfills;i++) h.Fill(r1.Rndm());
   printf("Time for TRandom  = %f seconds\n",timer.CpuTime()-fillTime);
}
