-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Export MemoryStats class to Python. Refs #6614
- Loading branch information
1 parent
1670a84
commit 2f43257
Showing
4 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
Code/Mantid/Framework/PythonInterface/mantid/kernel/src/Exports/Memory.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "MantidKernel/Memory.h" | ||
#include <boost/python/class.hpp> | ||
|
||
using Mantid::Kernel::MemoryStats; | ||
using namespace boost::python; | ||
|
||
void export_MemoryStats() | ||
{ | ||
|
||
class_< MemoryStats>("MemoryStats", init<>("Construct MemoryStats object.")) | ||
.def("update", &MemoryStats::update) | ||
.def("totalMem", &MemoryStats::totalMem) | ||
.def("availMem", &MemoryStats::availMem) | ||
.def("residentMem", &MemoryStats::residentMem) | ||
.def("virtualMem", &MemoryStats::virtualMem) | ||
.def("reservedMem", &MemoryStats::reservedMem) | ||
.def("getFreeRatio", &MemoryStats::getFreeRatio) | ||
; | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
Code/Mantid/Framework/PythonInterface/test/python/mantid/kernel/MemoryStatsTest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import unittest | ||
from mantid.kernel import MemoryStats | ||
|
||
class MemoryStatsTest(unittest.TestCase): | ||
|
||
def test_values_are_all_greater_than_zero(self): | ||
# Best we can do is test that something is returned | ||
mem = MemoryStats() | ||
|
||
self.assertTrue(hasattr(mem, "update")) | ||
self.assertGreater(mem.availMem, 0.0, "Value should be larger than 0.0") | ||
self.assertGreater(mem.totalMem, 0.0, "Value should be larger than 0.0") | ||
self.assertGreater(mem.residentMem, 0.0, "Value should be larger than 0.0") | ||
self.assertGreater(mem.virtualMem, 0.0, "Value should be larger than 0.0") | ||
self.assertGreater(mem.reservedMem, 0.0, "Value should be larger than 0.0") | ||
self.assertGreater(mem.getFreeRatio, 0.0, "Value should be larger than 0.0") | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |