MCPcopy Create free account
hub / github.com/pydata/numexpr / _get_cpu_info_from_sysinfo

Function _get_cpu_info_from_sysinfo

numexpr3/cpuinfo.py:1608–1663  ·  view source on GitHub ↗

Returns the CPU info gathered from sysinfo. Returns {} if sysinfo is not found.

()

Source from the content-addressed store, hash-verified

1606 return {}
1607
1608def _get_cpu_info_from_sysinfo():
1609 '''
1610 Returns the CPU info gathered from sysinfo.
1611 Returns {} if sysinfo is not found.
1612 '''
1613 try:
1614 # Just return {} if there is no sysinfo
1615 if not DataSource.has_sysinfo():
1616 return {}
1617
1618 # If sysinfo fails return {}
1619 returncode, output = DataSource.sysinfo_cpu()
1620 if output == None or returncode != 0:
1621 return {}
1622
1623 # Various fields
1624 vendor_id = '' #_get_field(False, output, None, None, 'CPU #0: ')
1625 processor_brand = output.split('CPU #0: "')[1].split('"\n')[0]
1626 cache_size = '' #_get_field(False, output, None, None, 'machdep.cpu.cache.size')
1627 stepping = int(output.split(', stepping ')[1].split(',')[0].strip())
1628 model = int(output.split(', model ')[1].split(',')[0].strip())
1629 family = int(output.split(', family ')[1].split(',')[0].strip())
1630
1631 # Flags
1632 flags = []
1633 for line in output.split('\n'):
1634 if line.startswith('\t\t'):
1635 for flag in line.strip().lower().split():
1636 flags.append(flag)
1637 flags.sort()
1638
1639 # Convert from GHz/MHz string to Hz
1640 scale, hz_advertised = _get_hz_string_from_brand(processor_brand)
1641 hz_actual = hz_advertised
1642
1643 info = {
1644 'vendor_id' : vendor_id,
1645 'brand' : processor_brand,
1646
1647 'hz_advertised' : to_friendly_hz(hz_advertised, scale),
1648 'hz_actual' : to_friendly_hz(hz_actual, scale),
1649 'hz_advertised_raw' : to_raw_hz(hz_advertised, scale),
1650 'hz_actual_raw' : to_raw_hz(hz_actual, scale),
1651
1652 'l2_cache_size' : to_friendly_bytes(cache_size),
1653
1654 'stepping' : stepping,
1655 'model' : model,
1656 'family' : family,
1657 'flags' : flags
1658 }
1659
1660 info = {k: v for k, v in info.items() if v}
1661 return info
1662 except:
1663 return {}
1664
1665def _get_cpu_info_from_registry():

Callers 1

get_cpu_infoFunction · 0.85

Calls 6

to_friendly_hzFunction · 0.85
to_raw_hzFunction · 0.85
to_friendly_bytesFunction · 0.85
has_sysinfoMethod · 0.80
sysinfo_cpuMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…