summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2016-02-02 00:08:46 +0000
committerGiampaolo Rodola <g.rodola@gmail.com>2016-02-02 00:08:46 +0000
commit350eeb16435c159b7d5403038e9fc137e12078f3 (patch)
treeaa7bbee9c3a57c42c33b589a33a79c782812007a
parente3e575b10c5bd270b1436d7711bc16c73b073e67 (diff)
downloadpsutil-350eeb16435c159b7d5403038e9fc137e12078f3.tar.gz
#779 / proc cpu times: sunos impl
-rw-r--r--psutil/_pssunos.py5
-rw-r--r--psutil/_psutil_sunos.c10
-rw-r--r--psutil/tests/test_process.py2
3 files changed, 11 insertions, 6 deletions
diff --git a/psutil/_pssunos.py b/psutil/_pssunos.py
index e76b40d7..f5ea5878 100644
--- a/psutil/_pssunos.py
+++ b/psutil/_pssunos.py
@@ -59,6 +59,8 @@ TCP_STATUSES = {
}
scputimes = namedtuple('scputimes', ['user', 'system', 'idle', 'iowait'])
+pcputimes = namedtuple('pcputimes',
+ ['user', 'system', 'children_user', 'children_system'])
svmem = namedtuple('svmem', ['total', 'available', 'percent', 'used', 'free'])
pmem = namedtuple('pmem', ['rss', 'vms'])
pmmap_grouped = namedtuple('pmmap_grouped',
@@ -363,8 +365,7 @@ class Process(object):
@wrap_exceptions
def cpu_times(self):
- user, system = cext.proc_cpu_times(self.pid, self._procfs_path)
- return _common.pcputimes(user, system)
+ return pcputimes(*cext.proc_cpu_times(self.pid, self._procfs_path))
@wrap_exceptions
def terminal(self):
diff --git a/psutil/_psutil_sunos.c b/psutil/_psutil_sunos.c
index 7ffee306..9a7067d3 100644
--- a/psutil/_psutil_sunos.c
+++ b/psutil/_psutil_sunos.c
@@ -159,9 +159,13 @@ psutil_proc_cpu_times(PyObject *self, PyObject *args) {
if (! psutil_file_to_struct(path, (void *)&info, sizeof(info)))
return NULL;
// results are more precise than os.times()
- return Py_BuildValue("dd",
- PSUTIL_TV2DOUBLE(info.pr_utime),
- PSUTIL_TV2DOUBLE(info.pr_stime));
+ return Py_BuildValue(
+ "(dddd)",
+ PSUTIL_TV2DOUBLE(info.pr_utime),
+ PSUTIL_TV2DOUBLE(info.pr_stime),
+ PSUTIL_TV2DOUBLE(info.pr_cutime),
+ PSUTIL_TV2DOUBLE(info.pr_cstime)
+ );
}
diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py
index f52d629a..8a557f60 100644
--- a/psutil/tests/test_process.py
+++ b/psutil/tests/test_process.py
@@ -267,7 +267,7 @@ class TestProcess(unittest.TestCase):
def test_cpu_times(self):
times = psutil.Process().cpu_times()
assert (times.user > 0.0) or (times.system > 0.0), times
- if LINUX:
+ if LINUX or BSD or SUNOS:
assert (times.children_user >= 0.0), times
assert (times.children_system >= 0.0), times
# make sure returned values can be pretty printed with strftime