Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions cpu_cores/darwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ def _count(self, command=None):
for line in lines:
tmp = line.strip()
if tmp.startswith(b'Total Number of Cores:'):
self._physical_cores_count = int(tmp.split(b':')[1])
if tmp.startswith(b'Number of Processors:'):
tmp = int(tmp.split(b':')[1].split(b'(')[0])
self._physical_cores_count = tmp
elif tmp.startswith(b'Number of Processors:'):
self._physical_processors_count = int(tmp.split(b':')[1])
if self._physical_processors_count is None or \
self._physical_cores_count is None:
if self._physical_cores_count is None:
raise Exception('impossible to get the cpu cores count (darwin)')
if self._physical_processors_count is None:
self._physical_processors_count = 1
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-r pip-requirements.txt

nose==1.2.1
nose==1.3.7
coverage==3.6
16 changes: 16 additions & 0 deletions tests/darwin2
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Hardware:

Hardware Overview:

Model Name: MacBook Pro
Model Identifier: MacBookPro18,4
Chip: Apple M1 Max
Total Number of Cores: 10 (8 performance and 2 efficiency)
Memory: 64 GB
System Firmware Version: 7429.41.5
OS Loader Version: 7429.41.5
Serial Number (system): Y0XXXXXXXX
Hardware UUID: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF
Provisioning UDID: 00006001-FFFFFFFFFFFFFFFF
Activation Lock Status: Disabled

5 changes: 5 additions & 0 deletions tests/test_darwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ def test_darwin_count1(self):
self.assertEqual(x._physical_cores_count, 2)
self.assertEqual(x._physical_processors_count, 1)

def test_darwin_count2(self):
x = self._test_darwin_count()
x._count('cat %s' % os.path.join(self._dir(), 'darwin2'))
self.assertEqual(x._physical_cores_count, 10)
self.assertEqual(x._physical_processors_count, 1)

if __name__ == '__main__':
unittest.main()