Skip to content

Commit

Permalink
rename variables and methods using camelcase for consistency with his…
Browse files Browse the repository at this point in the history
…torical code
  • Loading branch information
anton-ubi committed Aug 14, 2024
1 parent 31c22c3 commit d8e4190
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions rqd/rqd/rqmachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ def __initMachineStats(self, pathCpuInfo=None):
hyperthreadingMultiplier = 1

if platform.system() == 'Windows':
logicalCoreCount, __numProcs, hyperthreadingMultiplier = self.__init_stats_from_windows()
logicalCoreCount, __numProcs, hyperthreadingMultiplier = self.__initStatsFromWindows()
__totalCores = logicalCoreCount * rqd.rqconstants.CORE_VALUE

# All other systems will just have one proc/core
Expand Down Expand Up @@ -662,7 +662,7 @@ def __initMachineStats(self, pathCpuInfo=None):
if hyperthreadingMultiplier >= 1:
self.__renderHost.attributes['hyperthreadingMultiplier'] = str(hyperthreadingMultiplier)

def __init_stats_from_windows(self):
def __initStatsFromWindows(self):
"""Init machine stats for Windows platforms.
@rtype: tuple
Expand All @@ -681,17 +681,17 @@ def __init_stats_from_windows(self):
self.__renderHost.total_swap = int(stat.ullTotalPageFile / 1024)

# Windows CPU information
self.__update_procs_mappings_from_windows()
self.__updateProcsMappingsFromWindows()

logical_core_count = psutil.cpu_count(logical=True)
actual_core_count = psutil.cpu_count(logical=False)
hyper_threading_multiplier = logical_core_count // actual_core_count
logicalCoreCount = psutil.cpu_count(logical=True)
actualCoreCount = psutil.cpu_count(logical=False)
hyperThreadingMultiplier = logicalCoreCount // actualCoreCount

physical_processor_count = len(self.__procs_by_physid_and_coreid)
physicalProcessorCount = len(self.__procs_by_physid_and_coreid)

return logical_core_count, physical_processor_count, hyper_threading_multiplier
return logicalCoreCount, physicalProcessorCount, hyperThreadingMultiplier

def __update_procs_mappings_from_windows(self):
def __updateProcsMappingsFromWindows(self):
"""Update `__procs_by_physid_and_coreid` and `__physid_and_coreid_by_proc` mappings for Windows platforms.
Implementation detail.
Expand All @@ -703,24 +703,24 @@ def __update_procs_mappings_from_windows(self):
self.__physid_and_coreid_by_proc = {}

# Connect to the Windows Management Instrumentation (WMI) interface
wmi_instance = wmi.WMI()
wmiInstance = wmi.WMI()

# Retrieve CPU information using WMI
for physical_id, processor in enumerate(wmi_instance.Win32_Processor()):
for physicalId, processor in enumerate(wmiInstance.Win32_Processor()):

thread_per_core = processor.NumberOfLogicalProcessors // processor.NumberOfCores
proc_id = 0
threadPerCore = processor.NumberOfLogicalProcessors // processor.NumberOfCores
procId = 0

for core_id in range(processor.NumberOfCores):
for _ in range(thread_per_core):
for _ in range(threadPerCore):
self.__procs_by_physid_and_coreid.setdefault(
str(physical_id), {}
).setdefault(str(core_id), set()).add(str(proc_id))
self.__physid_and_coreid_by_proc[str(proc_id)] = (
str(physical_id),
str(physicalId), {}
).setdefault(str(core_id), set()).add(str(procId))
self.__physid_and_coreid_by_proc[str(procId)] = (
str(physicalId),
str(core_id),
)
proc_id += 1
procId += 1

def getWindowsMemory(self):
"""Gets information on system memory, Windows compatible version."""
Expand Down

0 comments on commit d8e4190

Please sign in to comment.