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"
7
#include "
storm/utility/OsDetection.h
"
8
#include "
storm/utility/macros.h
"
9
10
namespace
storm
{
11
namespace
utility {
12
namespace
resources {
13
18
inline
std::size_t
usedCPU
() {
19
return
std::size_t(clock()) / CLOCKS_PER_SEC;
20
}
21
26
inline
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
41
inline
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
OsDetection.h
STORM_LOG_WARN
#define STORM_LOG_WARN(message)
Definition
logging.h:30
macros.h
storm::utility::resources::setMemoryLimit
void setMemoryLimit(std::size_t megabytes)
Set memory limit.
Definition
resources.h:41
storm::utility::resources::usedCPU
std::size_t usedCPU()
Get used CPU time.
Definition
resources.h:18
storm::utility::resources::getMemoryLimit
std::size_t getMemoryLimit()
Get memory limit.
Definition
resources.h:26
storm
LabParser.cpp.
Definition
cli.cpp:18
src
storm-cli-utilities
resources.h
Generated by
1.9.8