From ed2c2eb112e80d8a10406a6eb3f9e4f58557e2c0 Mon Sep 17 00:00:00 2001 From: ferreo Date: Mon, 2 Sep 2024 22:38:01 +0100 Subject: [PATCH] Fix intel --- .github/release-nest-v3 | 2 +- debian/changelog | 6 ++++++ main.go | 27 ++++++++++++++++++--------- main.sh | 2 +- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/.github/release-nest-v3 b/.github/release-nest-v3 index 56a6051..d8263ee 100644 --- a/.github/release-nest-v3 +++ b/.github/release-nest-v3 @@ -1 +1 @@ -1 \ No newline at end of file +2 \ No newline at end of file diff --git a/debian/changelog b/debian/changelog index 84df4c8..12554ca 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +falcon (1.0.2-101pika1) pika; urgency=low + + * Fix Intel + + -- Ward Nakchbandi Sat, 10 Dec 2022 13:48:00 +0300 + falcon (1.0.1-101pika1) pika; urgency=low * Initial release diff --git a/main.go b/main.go index abf3193..79c7735 100644 --- a/main.go +++ b/main.go @@ -204,16 +204,25 @@ func GetPPStatusAndHighestCores() (bool, []CoreFreq, bool, []int, error) { return fmt.Errorf("failed to unmarshal lscpu output: %w", err) } - var maxMHz float64 - for _, cpu := range lscpuOutput.CPUs { - if cpu.MaxMHz > maxMHz { - maxMHz = cpu.MaxMHz - } - } + sort.Slice(lscpuOutput.CPUs, func(i, j int) bool { + return lscpuOutput.CPUs[i].MaxMHz > lscpuOutput.CPUs[j].MaxMHz + }) - for _, cpu := range lscpuOutput.CPUs { - if cpu.MaxMHz == maxMHz { - highestCores = append(highestCores, cpu.CPU) + if len(lscpuOutput.CPUs) > 0 { + topMHz := lscpuOutput.CPUs[0].MaxMHz + secondMHz := topMHz + + for _, cpu := range lscpuOutput.CPUs { + if cpu.MaxMHz < topMHz { + secondMHz = cpu.MaxMHz + break + } + } + + for _, cpu := range lscpuOutput.CPUs { + if cpu.MaxMHz == topMHz || cpu.MaxMHz == secondMHz { + highestCores = append(highestCores, cpu.CPU) + } } } diff --git a/main.sh b/main.sh index 065dd68..459edbc 100755 --- a/main.sh +++ b/main.sh @@ -2,7 +2,7 @@ set -e -VERSION="1.0.1" +VERSION="1.0.2" source ./pika-build-config.sh