Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
resources.h
Go to the documentation of this file.
1#pragma once
2#include <sys/resource.h>
3#include <sys/time.h>
4#include <sys/times.h>
5
6#include "storm-config.h"
9
10namespace storm {
11namespace utility {
12namespace resources {
13
18inline std::size_t usedCPU() {
19 return std::size_t(clock()) / CLOCKS_PER_SEC;
20}
21
26inline std::size_t getMemoryLimit() {
27#if defined LINUX
28 rlimit rl;
29 getrlimit(RLIMIT_AS, &rl);
30 return rl.rlim_cur;
31#else
32 STORM_LOG_WARN("Retrieving the memory limit is not supported for your operating system.");
33 return 0;
34#endif
35}
36
41inline void setMemoryLimit(std::size_t megabytes) {
42#if defined LINUX
43 rlimit rl;
44 getrlimit(RLIMIT_AS, &rl);
45 rl.rlim_cur = megabytes * 1024 * 1024;
46 setrlimit(RLIMIT_AS, &rl);
47#else
48 (void)megabytes; // To silence "unused" warning
49 STORM_LOG_WARN("Setting a memory limit is not supported for your operating system.");
50#endif
51}
52
53} // namespace resources
54} // namespace utility
55} // namespace storm
#define STORM_LOG_WARN(message)
Definition logging.h:30
void setMemoryLimit(std::size_t megabytes)
Set memory limit.
Definition resources.h:41
std::size_t usedCPU()
Get used CPU time.
Definition resources.h:18
std::size_t getMemoryLimit()
Get memory limit.
Definition resources.h:26
LabParser.cpp.
Definition cli.cpp:18