#ifndef ROOT_TMEMSTATINFO
#define ROOT_TMEMSTATINFO
#include <iosfwd>
#include <iomanip>
#include <sstream>
#include "TROOT.h"
#include "TObject.h"
#include "TMemStatHelpers.h"
class TMemStatStackInfo;
class TMemStatManager;
const int fields_length[] = {18, 15, 19, 12, 8};
class TMemStatInfoStamp: public TObject
{
public:
enum EStampType { kCode, kStack };
TMemStatInfoStamp();
virtual ~TMemStatInfoStamp();
void Print(Option_t* option = "") const;
Bool_t Equal(TMemStatInfoStamp&stamp);
void Inc(Int_t memSize);
void Dec(Int_t memSize);
friend std::ostream& operator<< (std::ostream &_ostream, const TMemStatInfoStamp &_this);
Long64_t fTotalAllocCount;
Long64_t fTotalAllocSize;
Int_t fAllocCount;
Int_t fAllocSize;
Int_t fStampNumber;
Int_t fID;
Short_t fStampType;
ClassDef(TMemStatInfoStamp, 1)
};
class TMemStatCodeInfo: public TObject
{
public:
TMemStatCodeInfo();
void SetInfo(void *info);
virtual ~TMemStatCodeInfo() {
}
void MakeStamp(Int_t stampNumber);
void Print(Option_t* option = "") const;
void Inc(Int_t memSize);
void Dec(Int_t memSize);
friend std::ostream& operator<< (std::ostream &_ostream, const TMemStatCodeInfo &_this);
TMemStatInfoStamp fLastStamp;
TMemStatInfoStamp fCurrentStamp;
TMemStatInfoStamp fMaxStampSize;
TMemStatInfoStamp fMaxStamp;
Long64_t fCode;
TString fInfo;
TString fFunction;
TString fLib;
UInt_t fCodeID;
ClassDef(TMemStatCodeInfo, 1)
};
class TMemStatStackInfo: public TObject
{
public:
enum {kStackHistorySize = 50};
UInt_t fSize;
TMemStatInfoStamp fLastStamp;
TMemStatInfoStamp fCurrentStamp;
TMemStatInfoStamp fMaxStampSize;
TMemStatInfoStamp fMaxStamp;
Int_t fNextHash;
void **fStackSymbols;
UInt_t *fSymbolIndexes;
UInt_t fStackID;
TMemStatStackInfo();
virtual ~TMemStatStackInfo() {}
void Init(Int_t stacksize, void **stackptrs, TMemStatManager *manager, Int_t ID);
void Inc(Int_t memSize, TMemStatManager *manager);
void Dec(Int_t memSize, TMemStatManager *manager);
ULong_t Hash() const;
Int_t Equal(UInt_t size, void **ptr);
void *StackAt(UInt_t i);
void MakeStamp(Int_t stampNumber);
static inline ULong_t HashStack(UInt_t size, void **ptr) {
return TString::Hash(ptr, size*sizeof(void*));
}
friend std::ostream& operator << (std::ostream &_ostream, const TMemStatStackInfo &_this);
ClassDef(TMemStatStackInfo, 1)
};
inline void TMemStatInfoStamp::Inc(int memSize)
{
fTotalAllocCount += 1;
fTotalAllocSize += memSize;
fAllocCount += 1;
fAllocSize += memSize;
}
inline void TMemStatInfoStamp::Dec(int memSize)
{
fAllocCount -= 1;
fAllocSize -= memSize;
}
inline void TMemStatCodeInfo::Dec(int memSize)
{
fCurrentStamp.Dec(memSize);
}
inline ULong_t TMemStatStackInfo::Hash() const
{
return HashStack(fSize, fStackSymbols);
}
inline void *TMemStatStackInfo::StackAt(UInt_t i)
{
return i < fSize ? fStackSymbols[i] : 0;
}
template<class T>
std::ostream& StreemCurrAndMax(std::ostream &_ostream, const T &_this)
{
std::ios::fmtflags old_flags(_ostream.flags(std::ios::left));
_ostream << "\n"
<< std::setw(fields_length[0]) << ""
<< std::setw(fields_length[1]) << "TotalCount"
<< std::setw(fields_length[2]) << "TotalSize"
<< std::setw(fields_length[3]) << "Count"
<< std::setw(fields_length[4]) << "Size" << std::endl;
std::locale loc("");
std::locale loc_previous = _ostream.imbue(loc);
_ostream.precision(2);
_ostream << std::fixed;
_ostream << std::setw(fields_length[0]) << "Current stamp";
_ostream
<< std::setw(fields_length[1]) << _this.fCurrentStamp.fTotalAllocCount
<< std::setw(fields_length[2]) << Memstat::dig2bytes(_this.fCurrentStamp.fTotalAllocSize)
<< std::setw(fields_length[3]) << _this.fCurrentStamp.fAllocCount
<< std::setw(fields_length[4]) << Memstat::dig2bytes(_this.fCurrentStamp.fAllocSize) << std::endl;
_ostream << std::setw(fields_length[0]) << "Max Alloc stamp";
_ostream
<< std::setw(fields_length[1]) << _this.fMaxStamp.fTotalAllocCount
<< std::setw(fields_length[2]) << Memstat::dig2bytes(_this.fMaxStamp.fTotalAllocSize)
<< std::setw(fields_length[3]) << _this.fMaxStamp.fAllocCount
<< std::setw(fields_length[4]) << Memstat::dig2bytes(_this.fMaxStamp.fAllocSize) << std::endl;
_ostream << std::setw(fields_length[0]) << "Max Size stamp";
_ostream
<< std::setw(fields_length[1]) << _this.fMaxStampSize.fTotalAllocCount
<< std::setw(fields_length[2]) << Memstat::dig2bytes(_this.fMaxStampSize.fTotalAllocSize)
<< std::setw(fields_length[3]) << _this.fMaxStampSize.fAllocCount
<< std::setw(fields_length[4]) << Memstat::dig2bytes(_this.fMaxStampSize.fAllocSize);
_ostream.imbue(loc_previous);
_ostream.flags(old_flags);
return _ostream;
}
#endif
Last change: Fri Jul 4 14:51:20 2008
Last generated: 2008-07-04 14:51
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.