Debian Codegraph @

plyer/facades/cpu.py

raw symbols SCIP
1 '''
2 CPU
3 ===
4
5 Simple Example
6 ---------------
7
8 To get CPU count::
9 >>> from plyer import cpu
10 >>> # 1 socket, 1 core per socket, 2 threads per core
11 >>> cpu.sockets # 1 CPU socket (or slot)
12 1
13 >>> cpu.physical # 1 CPU socket * 1 core per socket
14 1
15 >>> cpu.logical # 1 CPU socket * 1 core per socket * 2 threads per core
16 2
17
18 Supported Platforms
19 -------------------
20
21 MacOS
22 Linux
23 Windows
24 '''
25
26
27 class CPU:
28 '''
29 Facade providing info about sockets, physical and logical
30 number of processors.
31 '''
32
33 @property
34 def sockets(self):
35 '''
36 Property that contains the count of CPU sockets.
37 '''
38 return self._sockets()
39
40 @property
41 def physical(self):
42 '''
43 Property that contains the total number of physical cores
44 (max core count) in the system.
45
46 .. note:: `sockets * cores per socket`
47 '''
48 return self._physical()
49
50 @property
51 def logical(self):
52 '''
53 Property that contains the total number of logical cores
54 (max thread count) in the system.
55
56 .. note:: `sockets * cores per socket * threads per core`
57 '''
58 return self._logical()
59
60 @property
61 def cache(self):
62 '''
63 Property that contains the count of L1, L2, L3 caches in the system
64 as a dictionary `{'L1': int, 'L2': int, 'L3': int}`.
65 '''
66 return self._cache()
67
68 @property
69 def numa(self):
70 '''
71 Property that contains the count of NUMA nodes in the system.
72
73 .. note:: https://en.wikipedia.org/wiki/Non-uniform_memory_access
74 '''
75 return self._numa()
76
77 # private
78
79 def _sockets(self):
80 raise NotImplementedError()
81
82 def _physical(self):
83 raise NotImplementedError()
84
85 def _logical(self):
86 raise NotImplementedError()
87
88 def _cache(self):
89 raise NotImplementedError()
90
91 def _numa(self):
92 raise NotImplementedError()