Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
osutils.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file ored/utilities/osutils.hpp
20 \brief Various OS specific utilities
21 \ingroup utilities
22*/
23
24#pragma once
25
26#include <string>
27
28namespace ore {
29namespace data {
30namespace os {
31
32/*! \addtogroup utilities
33 @{
34*/
35//! Returns the OS Name
36std::string getOsName();
37
38//! Returns the OS Version
39std::string getOsVersion();
40
41//! Returns the CPU name (e.g. "Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz"
42std::string getCpuName();
43
44//! Returns the number of Cores available to the OS.
45unsigned int getNumberCores();
46
47//! Returns the total amount of memory available (installed RAM)
48std::string getMemoryRAM();
49
50//! Returns the current process memory usage
51std::string getMemoryUsage();
52
53//! Returns the current process peak memory usage
54std::string getPeakMemoryUsage();
55
56/*! Returns the current process memory usage in bytes
57 Parts of code taken from:
58 http://nadeausoftware.com/articles/2012/07/c_c_tip_how_get_process_resident_set_size_physical_memory_use
59*/
60unsigned long long getMemoryUsageBytes();
61
62//! Returns the current process peak memory usage in bytes
63unsigned long long getPeakMemoryUsageBytes();
64
65//! Returns the current username
66std::string getUsername();
67
68//! Returns the machine name
69std::string getHostname();
70
71//! Returns all the above system details in a single string
72std::string getSystemDetails();
73
74//! Write the current stacktrace to stderr and LOG() with level = ALERT
75void dumpStacktrace();
76
77//! Set an assert handler that logs the stacktrace
78void setAssertHandler();
79
80//! @}
81}; // namespace os
82} // namespace data
83} // namespace ore
string getPeakMemoryUsage()
Returns the current process peak memory usage.
Definition: osutils.cpp:101
string getCpuName()
Returns the CPU name (e.g. "Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz".
Definition: osutils.cpp:327
string getMemoryUsage()
Returns the current process memory usage.
Definition: osutils.cpp:99
string getHostname()
Returns the machine name.
Definition: osutils.cpp:226
string getUsername()
Returns the current username.
Definition: osutils.cpp:217
string getOsName()
Returns the OS Name.
Definition: osutils.cpp:284
void setAssertHandler()
Set an assert handler that logs the stacktrace.
Definition: osutils.cpp:405
string getMemoryRAM()
Returns the total amount of memory available (installed RAM)
Definition: osutils.cpp:350
void dumpStacktrace()
Write the current stacktrace to stderr and LOG() with level = ALERT.
Definition: osutils.cpp:361
string getOsVersion()
Returns the OS Version.
Definition: osutils.cpp:296
string getSystemDetails()
Returns all the above system details in a single string.
Definition: osutils.cpp:82
unsigned long long getPeakMemoryUsageBytes()
Returns the current process peak memory usage in bytes.
Definition: osutils.cpp:207
unsigned long long getMemoryUsageBytes()
Definition: osutils.cpp:337
unsigned int getNumberCores()
Returns the number of Cores available to the OS.
Definition: osutils.cpp:329
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23