Skip to content

Commit

Permalink
fixes the freq problem
Browse files Browse the repository at this point in the history
  • Loading branch information
ribalba committed Feb 16, 2024
1 parent 86b7054 commit e4f9820
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions auto_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def get_cpu_info(logger):

try:
cpuinfo = subprocess.check_output('lscpu', encoding='UTF-8')

match = re.search(r'On-line CPU\(s\) list:\s*(0-)?(\d+)', cpuinfo)
if match:
data['threads'] = int(match.group(2))+1 # +1 because 0 indexed
Expand Down Expand Up @@ -95,7 +96,12 @@ def get_cpu_info(logger):
data['freq'] = int(float(match.group(1))*1000)
logger.info('Found Frequency: %s', data['freq'])
else:
logger.info('Could not find Frequency. Using default None')
match = re.search(r'CPU max MHz:\s+([\d.]+)', cpuinfo)
if match:
data['freq'] = int(float(match.group(1)))
logger.info('Found Frequency: %s', data['freq'])
else:
logger.info('Could not find Frequency. Using default None')

match = re.search(r'Model name:.*Intel\(R\)', cpuinfo)
if match:
Expand Down Expand Up @@ -157,6 +163,5 @@ def get_cpu_info(logger):
if __name__ == "__main__":
logger = logging.getLogger(__name__)
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.INFO)

logger.setLevel(logging.DEBUG)
print(get_cpu_info(logger))

0 comments on commit e4f9820

Please sign in to comment.