Skip to content

Commit

Permalink
Export MemoryStats class to Python. Refs #6614
Browse files Browse the repository at this point in the history
  • Loading branch information
martyngigg committed Feb 25, 2013
1 parent 1670a84 commit 2f43257
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ set ( EXPORT_FILES
src/Exports/UnitFactory.cpp
src/Exports/DeltaEMode.cpp
src/Exports/PropertyManager.cpp
src/Exports/Memory.cpp
)

set ( SRC_FILES
Expand Down
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)
;

}


Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ set ( TEST_PY_FILES
LogFilterTest.py
LoggerTest.py
MandatoryValidatorTest.py
MemoryStatsTest.py
NullValidatorTest.py
PropertyWithValueTest.py
PythonPluginsTest.py
Expand Down
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()

0 comments on commit 2f43257

Please sign in to comment.