#12828: get_memory_usage and top under FreeBSD
--------------------------------------------+-------------------------------
Reporter: stephen | Owner: pjeremy
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-5.8
Component: FreeBSD | Resolution:
Keywords: | Work issues:
Report Upstream: N/A | Reviewers:
Authors: Stephen Montgomery-Smith | Merged in:
Dependencies: | Stopgaps:
--------------------------------------------+-------------------------------
Changes (by kcrisman):
* status: new => needs_review
Old description:
> Suggested changes to sage/misc/getusage.py:
>
> {{{
> --- sage-5.0.beta13/sage/misc/getusage.py-orig 2012-04-11
> 00:14:47.000000000 +0000
> +++ sage-5.0.beta13/sage/misc/getusage.py 2012-04-11
> 00:47:03.000000000 +0000
> @@ -20,6 +20,8 @@
> """
> Return the 'top' or 'prstat' line that contains this running Sage
> process.
> + For FreeBSD, return the line containing this running Sage process
> from
> + 'ps -axwww -o pid,user,vsz,rss,state,pri,nice,time,cpu,comm'.
>
> OUTPUT:
>
> @@ -53,6 +55,8 @@
> cmd = 'top -l 1 |grep "^ *%s "' % pid
> elif U == 'sunos':
> cmd = '/usr/bin/prstat -n 100000 1 1 | grep "^ *%s "' % pid
> + elif U == 'freebsd':
> + cmd = 'ps -axwww -o
> pid,user,vsz,rss,state,pri,nice,time,cpu,comm | grep "^ *%s "' % pid
> else:
> raise NotImplementedError("top not implemented on platform %s" %
> U)
>
> @@ -83,6 +87,9 @@
> usage, ``prstat`` will output the data in KB, MB or GB. In each
> case, the value returned by this function will always be in MB.
>
> + - ``FreeBSD`` - Returns float number (in megabytes) that matches
> + RSS column of ``ps -auxwww``
> +
> - ``other`` - not implemented for any other operating systems
>
> EXAMPLES::
> @@ -129,6 +136,9 @@
> m = float(memory_in_KB_MB_or_GB.strip("M"))
> elif memory_in_KB_MB_or_GB.endswith("G"):
> m = float(memory_in_KB_MB_or_GB.strip("G")) * 1024
> + elif U == 'freebsd':
> + memory_in_KB = top().split()[3]
> + m = float(memory_in_KB) / 1024
> else:
> raise NotImplementedError("memory usage not implemented on
> platform %s" % U)
> }}}
New description:
Suggested changes to sage/misc/getusage.py:
{{{
--- sage-5.0.beta13/sage/misc/getusage.py-orig 2012-04-11
00:14:47.000000000 +0000
+++ sage-5.0.beta13/sage/misc/getusage.py 2012-04-11
00:47:03.000000000 +0000
@@ -20,6 +20,8 @@
"""
Return the 'top' or 'prstat' line that contains this running Sage
process.
+ For FreeBSD, return the line containing this running Sage process
from
+ 'ps -axwww -o pid,user,vsz,rss,state,pri,nice,time,cpu,comm'.
OUTPUT:
@@ -53,6 +55,8 @@
cmd = 'top -l 1 |grep "^ *%s "' % pid
elif U == 'sunos':
cmd = '/usr/bin/prstat -n 100000 1 1 | grep "^ *%s "' % pid
+ elif U == 'freebsd':
+ cmd = 'ps -axwww -o pid,user,vsz,rss,state,pri,nice,time,cpu,comm
| grep "^ *%s "' % pid
else:
raise NotImplementedError("top not implemented on platform %s" %
U)
@@ -83,6 +87,9 @@
usage, ``prstat`` will output the data in KB, MB or GB. In each
case, the value returned by this function will always be in MB.
+ - ``FreeBSD`` - Returns float number (in megabytes) that matches
+ RSS column of ``ps -auxwww``
+
- ``other`` - not implemented for any other operating systems
EXAMPLES::
@@ -129,6 +136,9 @@
m = float(memory_in_KB_MB_or_GB.strip("M"))
elif memory_in_KB_MB_or_GB.endswith("G"):
m = float(memory_in_KB_MB_or_GB.strip("G")) * 1024
+ elif U == 'freebsd':
+ memory_in_KB = top().split()[3]
+ m = float(memory_in_KB) / 1024
else:
raise NotImplementedError("memory usage not implemented on
platform %s" % U)
}}}
Apply [attachment:trac_12828.patch].
--
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12828#comment:4>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.