<commit_before>//*********************************************************************
//+ Evaluate the performance of THnSparse vs TH1/2/3/nF
//  for different numbers of dimensions and bins per dimension.
// 
//  The script calculates the bandwidth for filling and retrieving
//  bin contents (in million entries per second) for these two
//  histogramming techniques, where "seconds" is CPU and real time.
//
//  The first line of the plots contains the bandwidth based on the 
//  CPU time (THnSpase, TH1/2/3/nF*, ratio), the second line shows
//  the plots for real time, and the third line shows the fraction of
//  filled bins and memory used by THnSparse vs. TH1/2/3/nF.
// 
//  The timing depends on the distribution and the amount of entries
//  in the histograms; here, a Gaussian distribution (center is
//  contained in the histograms) is used to fill each histogram with
//  1000 entries. The filling and reading is repeated until enough
//  statistics have been collected.
// 
//  tutorials/tree/drawsparse.C shows an example for visualizing a
//  THnSparse. It creates a TTree which is then drawn using
//  TParallelCoord.
// 
//  This macro should be run in compiled mode due to the many nested
//  loops that force CINT to disable its optimization. If run
//  interpreted one would not benchmark THnSparse but CINT.
// 
//  Run as
//    .L $ROOTSYS/tutorials/hist/sparsehist.C+
// 
//  <EMAIL> (2007-09-14)
// *********************************************************************

#include "TH1.h"
#include "TH2.h"
#include "TH3.h"
#include "THn.h"
#include "THnSparse.h"
#include "TStopwatch.h"
#include "TRandom.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TStyle.h"
#include "TSystem.h"

class TTimeHists {
public:
   enum EHist { kHist, kSparse, kNumHist };
   enum ETime { kReal, kCPU, kNumTime };
   TTimeHists(Int_t dim, Int_t bins, Long_t num):
      fValue(0), fDim(dim), fBins(bins), fNum(num),
      fSparse(0), fHist(0), fHn(0) {}
   ~TTimeHists();
   bool Run();
   Double_t GetTime(EHist hist, ETime time) const {
      if (time == kReal) return fTime[hist][0];
      return fTime[hist][1]; }
   static void SetDebug(Int_t lvl) { fgDebug = lvl; }
   THnSparse* GetSparse() const { return fSparse; }

protected:
   void Fill(EHist hist);
   Double_t Check(EHist hist);
   void SetupHist(EHist hist);
   void NextValues();
   void SetupValues();

private:
   Double_t* fValue;
   Int_t fDim;
   Int_t fBins;
   Long_t fNum;
   Double_t fTime[2][2];<commit_msg>Fix this tutorial for root6<commit_after>//*********************************************************************
//+ Evaluate the performance of THnSparse vs TH1/2/3/nF
//  for different numbers of dimensions and bins per dimension.
// 
//  The script calculates the bandwidth for filling and retrieving
//  bin contents (in million entries per second) for these two
//  histogramming techniques, where "seconds" is CPU and real time.
//
//  The first line of the plots contains the bandwidth based on the 
//  CPU time (THnSpase, TH1/2/3/nF*, ratio), the second line shows
//  the plots for real time, and the third line shows the fraction of
//  filled bins and memory used by THnSparse vs. TH1/2/3/nF.
// 
//  The timing depends on the distribution and the amount of entries
//  in the histograms; here, a Gaussian distribution (center is
//  contained in the histograms) is used to fill each histogram with
//  1000 entries. The filling and reading is repeated until enough
//  statistics have been collected.
// 
//  tutorials/tree/drawsparse.C shows an example for visualizing a
//  THnSparse. It creates a TTree which is then drawn using
//  TParallelCoord.
// 
//  This macro should be run in compiled mode due to the many nested
//  loops that force CINT to disable its optimization. If run
//  interpreted one would not benchmark THnSparse but CINT.
// 
//  Run as
//    .L $ROOTSYS/tutorials/hist/sparsehist.C+
// 
//  <EMAIL> (2007-09-14)
// *********************************************************************

#include "TH1.h"
#include "TH2.h"
#include "TH3.h"
#include "THn.h"
#include "THnSparse.h"
#include "TStopwatch.h"
#include "TRandom.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TStyle.h"
#include "TSystem.h"

#ifndef INT_MAX
#define INT_MAX std::numeric_limits<int>::max()
#endif

class TTimeHists {
public:
   enum EHist { kHist, kSparse, kNumHist };
   enum ETime { kReal, kCPU, kNumTime };
   TTimeHists(Int_t dim, Int_t bins, Long_t num):
      fValue(0), fDim(dim), fBins(bins), fNum(num),
      fSparse(0), fHist(0), fHn(0) {}
   ~TTimeHists();
   bool Run();
   Double_t GetTime(EHist hist, ETime time) const {
      if (time == kReal) return fTime[hist][0];
      return fTime[hist][1]; }
   static void SetDebug(Int_t lvl) { fgDebug = lvl; }
   THnSparse* GetSparse() const { return fSparse; }

protected:
   void Fill(EHist hist);
   Double_t Check(EHist hist);
   void SetupHist(EHist hist);
   void NextValues();
   void SetupValues();

private:
   Double_t* fValue;
   Int_t fDim;
   Int_t fBins;
   Long_t fNum;
   Double_t fTime[2][2];
{'fraction_non_alphanumeric': 0.16155057064147973, 'fraction_numerical': 0.012790240062967336, 'mean_word_length': 3.571043165467626, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7192501', 'n_tokens_mistral': 1712, 'n_tokens_neox': 1655, 'n_words': 585}