Skip to content

Commit

Permalink
Merge pull request #46 from chrisbeardy/min_max_per_cpu
Browse files Browse the repository at this point in the history
min and max freq for each core now displayed, instead of overall
  • Loading branch information
bexxmodd authored Feb 7, 2022
2 parents 0d4239d + e653a12 commit 203be1d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions vizex/vizexdu/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,25 @@ def display_separately(self, save=True) -> None:
while True:
cpu = psutil.cpu_freq(percpu=True)

for n, i in enumerate(cpu, start=1):
percent = round((i.current - self._min) / (self._max - self._min) * 100, 2)
for i, core in enumerate(cpu, start=1):
min_freq, max_freq, current_freq = core.min, core.max, core.current
percent = round((current_freq - min_freq) / (max_freq - min_freq) * 100, 2)
ch.chart(
title=f'CPU #{n}',
pre_graph_text=f'Current: {round(i.current, 1)}MHz || Min: {self._min}MHz || Max: {self._max}MHz',
title=f'CPU #{i}',
pre_graph_text=f'Current: {round(current_freq, 1)}MHz || Min: {min_freq}MHz || Max: {max_freq}MHz',
post_graph_text=tools.create_usage_warning(percent, 30, 15),
footer=None,
maximum=self._max - self._min,
current=i.current - self._min
maximum=max_freq - min_freq,
current=current_freq - min_freq,
)

if save:
cpu = {
'user': [getpass.getuser()],
'cpu': [n],
'cpu': [i],
'time': [time.time()],
'current': [i.current],
'usage': [percent]
'current': [current_freq],
'usage': [percent],
}

tools.save_to_csv(cpu, '~/cpus.csv')
Expand All @@ -69,7 +70,6 @@ def display_separately(self, save=True) -> None:

time.sleep(0.8)
os.system('cls' if os.name == 'nt' else 'clear')
tools.save_to_csv(cpu, '~/cpu.csv')

def display_combined(self) -> None:
os.system('cls' if os.name == 'nt' else 'clear')
Expand Down

0 comments on commit 203be1d

Please sign in to comment.