OpenMS
SysInfo.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Chris Bielow $
6 // $Authors: Chris Bielow $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #include <OpenMS/config.h>
13 
14 namespace OpenMS
15 {
16 
18  OPENMS_DLLAPI std::string bytesToHumanReadable(UInt64 bytes);
19 
26  class OPENMS_DLLAPI SysInfo
27  {
28  public:
35  static bool getProcessMemoryConsumption(size_t& mem_virtual);
36 
43  static bool getProcessPeakMemoryConsumption(size_t& mem_virtual);
44 
60  struct OPENMS_DLLAPI MemUsage
61  {
62  size_t mem_before, mem_before_peak, mem_after, mem_after_peak;
63 
66 
68  void reset();
70  void before();
72  void after();
75  String delta(const String& event = "delta");
76 
80 
81  private:
82  // convert difference to string
83  String diff_str_(size_t mem_before, size_t mem_after);
84 
85  };
86  };
87 }
88 
A more convenient string class.
Definition: String.h:34
Some functions to get system information.
Definition: SysInfo.h:27
static bool getProcessMemoryConsumption(size_t &mem_virtual)
static bool getProcessPeakMemoryConsumption(size_t &mem_virtual)
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:51
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
std::string bytesToHumanReadable(UInt64 bytes)
convert bytes to a human readable unit (TiB, GiB, MiB, KiB), e.g. "45.34 MiB"
A convenience class to report either absolute or delta (between two timepoints) RAM usage.
Definition: SysInfo.h:61
String delta(const String &event="delta")
void before()
record data for the first timepoint
void after()
record data for the second timepoint
size_t mem_after
Definition: SysInfo.h:62
MemUsage()
C'tor, calls before() automatically.
String diff_str_(size_t mem_before, size_t mem_after)
void reset()
forget all data (you need to call before() again)