CbmRoot
Loading...
Searching...
No Matches
MemoryLogger.cxx
Go to the documentation of this file.
1
/* Copyright (C) 2024 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
2
SPDX-License-Identifier: GPL-3.0-only
3
Authors: Felix Weiglhofer [committer] */
4
5
#include "
MemoryLogger.h
"
6
7
#include "
AlgoFairloggerCompat.h
"
8
#include "
System.h
"
9
10
using namespace
cbm::algo
;
11
12
template
<
typename
T>
13
T
MemoryLogger::BytesToMB
(T bytes)
const
14
{
15
return
bytes / (1024 * 1024);
16
}
17
18
void
MemoryLogger::Log
()
19
{
20
size_t
currentRSS =
GetCurrentRSS
();
21
size_t
peakRSS =
GetPeakRSS
();
22
23
ptrdiff_t deltaRSS = currentRSS -
mLastRSS
;
24
float
deltaPercent = 100.0f * deltaRSS / currentRSS;
25
26
L_
(debug) <<
"Current memory usage: "
<<
BytesToMB
(currentRSS) <<
"MB (delta "
<<
BytesToMB
(deltaRSS) <<
"MB / "
27
<< deltaPercent <<
"%)"
28
<<
", peak: "
<<
BytesToMB
(peakRSS) <<
"MB"
;
29
30
mLastRSS
= currentRSS;
31
}
AlgoFairloggerCompat.h
L_
#define L_(level)
Definition
AlgoFairloggerCompat.h:18
MemoryLogger.h
Memory logging.
System.h
System functions.
cbm::algo::MemoryLogger::Log
void Log()
Log the current memory usage.
Definition
MemoryLogger.cxx:18
cbm::algo::MemoryLogger::mLastRSS
size_t mLastRSS
Definition
MemoryLogger.h:39
cbm::algo::MemoryLogger::BytesToMB
T BytesToMB(T bytes) const
Definition
MemoryLogger.cxx:13
cbm::algo
Definition
AlgoTraits.h:16
cbm::algo::GetCurrentRSS
size_t GetCurrentRSS()
Get the current resident set size (pyhysical memory usage) of the process.
Definition
System.cxx:15
cbm::algo::GetPeakRSS
size_t GetPeakRSS()
Get the peak resident set size (pyhysical memory usage) of the process.
Definition
System.cxx:35
algo
base
util
MemoryLogger.cxx
Generated on Sun Dec 22 2024 23:04:04 for CbmRoot by
1.12.0