summaryrefslogtreecommitdiffstats
path: root/xbmc/utils/CPUInfo.cpp
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
committermanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
commitbe933ef2241d79558f91796cc5b3a161f72ebf9c (patch)
treefe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/utils/CPUInfo.cpp
parent5f8335c1e49ce108ef3481863833c98efa00411b (diff)
downloadkodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip
sync with upstream
Diffstat (limited to 'xbmc/utils/CPUInfo.cpp')
-rw-r--r--xbmc/utils/CPUInfo.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/xbmc/utils/CPUInfo.cpp b/xbmc/utils/CPUInfo.cpp
new file mode 100644
index 0000000..d816d1e
--- /dev/null
+++ b/xbmc/utils/CPUInfo.cpp
@@ -0,0 +1,62 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#include "CPUInfo.h"
10
11#include "utils/StringUtils.h"
12
13bool CCPUInfo::HasCoreId(int coreId) const
14{
15 for (const auto& core : m_cores)
16 {
17 if (core.m_id == coreId)
18 return true;
19 }
20
21 return false;
22}
23
24const CoreInfo CCPUInfo::GetCoreInfo(int coreId)
25{
26 CoreInfo coreInfo;
27
28 for (auto& core : m_cores)
29 {
30 if (core.m_id == coreId)
31 coreInfo = core;
32 }
33
34 return coreInfo;
35}
36
37std::string CCPUInfo::GetCoresUsageString() const
38{
39 std::string strCores;
40
41 if (SupportsCPUUsage())
42 {
43 if (!m_cores.empty())
44 {
45 for (const auto& core : m_cores)
46 {
47 if (!strCores.empty())
48 strCores += ' ';
49 if (core.m_usagePercent < 10.0)
50 strCores += StringUtils::Format("#%d: %1.1f%%", core.m_id, core.m_usagePercent);
51 else
52 strCores += StringUtils::Format("#%d: %3.0f%%", core.m_id, core.m_usagePercent);
53 }
54 }
55 else
56 {
57 strCores += StringUtils::Format("%3.0f%%", static_cast<double>(m_lastUsedPercentage));
58 }
59 }
60
61 return strCores;
62}