def testStats(self): from mars import resource resource = reload_module(resource) resource.cpu_percent() mem_stats = resource.virtual_memory() self.assertGreaterEqual(mem_stats.available, 0) self.assertGreaterEqual(mem_stats.total, 0) self.assertGreaterEqual(mem_stats.percent, 0) self.assertGreaterEqual(mem_stats.used, 0) self.assertGreaterEqual(mem_stats.free, 0) cpu_usage = resource.cpu_percent() time.sleep(0.1) self.assertGreaterEqual(cpu_usage, 0) resource.disk_io_usage() time.sleep(0.1) recv_speed, send_speed = resource.disk_io_usage() self.assertGreaterEqual(recv_speed, 0) self.assertGreaterEqual(send_speed, 0) resource.net_io_usage() time.sleep(0.1) recv_speed, send_speed = resource.net_io_usage() self.assertGreaterEqual(recv_speed, 0) self.assertGreaterEqual(send_speed, 0)
def testStats(self): from mars import resource resource = importlib.reload(resource) resource.cpu_percent() mem_stats = resource.virtual_memory() self.assertGreaterEqual(mem_stats.available, 0) self.assertGreaterEqual(mem_stats.total, 0) self.assertGreaterEqual(mem_stats.percent, 0) self.assertGreaterEqual(mem_stats.used, 0) self.assertGreaterEqual(mem_stats.free, 0) cpu_usage = resource.cpu_percent() time.sleep(0.1) self.assertGreaterEqual(cpu_usage, 0) resource.disk_io_usage() time.sleep(0.1) recv_speed, send_speed = resource.disk_io_usage() self.assertGreaterEqual(recv_speed, 0) self.assertGreaterEqual(send_speed, 0) curdir = os.path.dirname(os.path.abspath(__file__)) resource.disk_io_usage(curdir) time.sleep(0.1) usage = resource.disk_io_usage(curdir) if usage is not None: self.assertGreaterEqual(usage.reads, 0) self.assertGreaterEqual(usage.writes, 0) resource.net_io_usage() time.sleep(0.1) recv_speed, send_speed = resource.net_io_usage() self.assertGreaterEqual(recv_speed, 0) self.assertGreaterEqual(send_speed, 0)
def test_stats(): from mars import resource resource = importlib.reload(resource) resource.cpu_percent() mem_stats = resource.virtual_memory() assert mem_stats.available >= 0 assert mem_stats.total >= 0 assert mem_stats.percent >= 0 assert mem_stats.used >= 0 assert mem_stats.free >= 0 cpu_usage = resource.cpu_percent() time.sleep(0.1) assert cpu_usage >= 0 resource.disk_io_usage() time.sleep(0.1) recv_speed, send_speed = resource.disk_io_usage() assert recv_speed >= 0 assert send_speed >= 0 curdir = os.path.dirname(os.path.abspath(__file__)) resource.disk_io_usage(curdir) time.sleep(0.1) usage = resource.disk_io_usage(curdir) if usage is not None: assert usage.reads >= 0 assert usage.writes >= 0 resource.net_io_usage() time.sleep(0.1) recv_speed, send_speed = resource.net_io_usage() assert recv_speed >= 0 assert send_speed >= 0