File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 2
2
#define MEMINFO_HPP
3
3
4
4
#include " util/log.hpp"
5
+ #include < cstddef>
5
6
6
7
#ifndef _WIN32
7
8
#include < sys/resource.h>
10
11
namespace osrm ::util
11
12
{
12
13
13
- inline void DumpMemoryStats ()
14
+ inline size_t PeakRAMUsedInBytes ()
14
15
{
15
16
#ifndef _WIN32
16
17
rusage usage;
17
18
getrusage (RUSAGE_SELF, &usage);
18
19
#ifdef __linux__
19
20
// Under linux, ru.maxrss is in kb
20
- util::Log () << " RAM: peak bytes used: " << usage.ru_maxrss * 1024 ;
21
+ return usage.ru_maxrss * 1024 ;
21
22
#else // __linux__
22
23
// Under BSD systems (OSX), it's in bytes
23
- util::Log () << " RAM: peak bytes used: " << usage.ru_maxrss ;
24
+ return usage.ru_maxrss ;
24
25
#endif // __linux__
26
+ #else // _WIN32
27
+ return 0 ;
28
+ #endif // _WIN32
29
+ }
30
+
31
+ inline void DumpMemoryStats ()
32
+ {
33
+ #ifndef _WIN32
34
+ util::Log () << " RAM: peak bytes used: " << PeakRAMUsedInBytes ();
25
35
#else // _WIN32
26
36
util::Log () << " RAM: peak bytes used: <not implemented on Windows>" ;
27
37
#endif // _WIN32
28
38
}
29
39
} // namespace osrm::util
30
40
31
- #endif
41
+ #endif
Original file line number Diff line number Diff line change 16
16
#include " osrm/osrm.hpp"
17
17
#include " osrm/status.hpp"
18
18
19
+ #include " util/meminfo.hpp"
19
20
#include < boost/assert.hpp>
20
-
21
21
#include < boost/optional/optional.hpp>
22
22
#include < cstdlib>
23
23
#include < exception>
655
655
std::cerr << " Unknown benchmark: " << benchmarkToRun << std::endl;
656
656
return EXIT_FAILURE;
657
657
}
658
+
659
+ std::cout << " Peak RAM: " << std::setprecision (3 )
660
+ << static_cast <double >(osrm::util::PeakRAMUsedInBytes ()) /
661
+ static_cast <double >((1024 * 1024 ))
662
+ << " MB" << std::endl;
663
+
658
664
return EXIT_SUCCESS;
659
665
}
660
666
catch (const std::exception &e)
You can’t perform that action at this time.
0 commit comments