Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/misc/darwin_utilities.pyx
4079 views
1
# darwin_utilities extension module built only on OS_X >= 10.5 (see end of module_list.py)
2
3
cdef extern from "darwin_memory_usage.h":
4
cdef unsigned long long darwin_virtual_size()
5
6
def darwin_memory_usage():
7
r"""
8
On Darwin >= 9 (i.e. OS X >= 10.5), returns the virtual size of the process in bytes.
9
This will match what "top" reports as the VSIZE.
10
Raises on all other platforms
11
12
EXAMPLES
13
sage: uname = os.uname()
14
sage: if uname[0] == 'Darwin' and not uname[2].startswith('8.'):
15
... from sage.misc.darwin_utilities import darwin_memory_usage
16
... memory_usage = darwin_memory_usage()
17
18
19
sage: uname = os.uname()
20
sage: if uname[0] == 'Darwin' and uname[2].startswith('8.'):
21
... try:
22
... from sage.misc.darwin_utilities import darwin_memory_usage
23
... memory_usage = darwin_memory_usage()
24
... print "doctest failure!"
25
... print "darwin_memory_usage() not implemented on platform Darwin 8 (i.e. OS X 10.4)"
26
... except ImportError:
27
... pass
28
29
30
sage: uname = os.uname()
31
sage: if uname[0] != 'Darwin':
32
... try:
33
... from sage.misc.darwin_utilities import darwin_memory_usage
34
... memory_usage = darwin_memory_usage()
35
... print "doctest failure!"
36
... print "darwin_memory_usage() not implemented on platform %s"%uname[0]
37
... except ImportError:
38
... pass
39
40
41
"""
42
return darwin_virtual_size()
43
44
45