Skip to content

Commit 45042c4

Browse files
committed
fix code style
1 parent 2a24369 commit 45042c4

File tree

110 files changed

+4183
-3189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+4183
-3189
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
*.pyc
2+
demos/build_ov_master/
3+
demos/build_ov_package/

demos/background_subtraction_demo/cpp_gapi/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,12 @@ int main(int argc, char* argv[]) {
238238
slog::info << "Metrics report:" << slog::endl;
239239
slog::info << "\tFPS: " << std::fixed << std::setprecision(1) << metrics.getTotal().fps << slog::endl;
240240
slog::info << presenter.reportMeans() << slog::endl;
241-
} catch (const std::exception& error) {
241+
}
242+
catch (const std::exception& error) {
242243
slog::err << error.what() << slog::endl;
243244
return 1;
244-
} catch (...) {
245+
}
246+
catch (...) {
245247
slog::err << "Unknown/internal exception happened." << slog::endl;
246248
return 1;
247249
}

demos/classification_benchmark_demo/cpp/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,12 @@ int main(int argc, char* argv[]) {
359359
pipeline.getPostprocessMetrics().getTotal().latency,
360360
renderMetrics.getTotal().latency);
361361
slog::info << presenter.reportMeans() << slog::endl;
362-
} catch (const std::exception& error) {
362+
}
363+
catch (const std::exception& error) {
363364
slog::err << error.what() << slog::endl;
364365
return 1;
365-
} catch (...) {
366+
}
367+
catch (...) {
366368
slog::err << "Unknown/internal exception happened." << slog::endl;
367369
return 1;
368370
}

demos/common/cpp/models/src/hpe_model_associative_embedding.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ void HpeAssociativeEmbedding::prepareInputsOutputs(std::shared_ptr<ov::Model>& m
105105
heatmapsTensorName = findTensorByName("heatmaps", outputsNames);
106106
try {
107107
nmsHeatmapsTensorName = findTensorByName("nms_heatmaps", outputsNames);
108-
} catch (const std::runtime_error&) { nmsHeatmapsTensorName = heatmapsTensorName; }
108+
}
109+
catch (const std::runtime_error&) {
110+
nmsHeatmapsTensorName = heatmapsTensorName;
111+
}
109112

110113
changeInputSize(model);
111114
}

demos/common/cpp/models/src/jpeg_restoration_model.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
// limitations under the License.
1515
*/
1616

17+
#include "models/jpeg_restoration_model.h"
18+
1719
#include <stddef.h>
1820

1921
#include <algorithm>
@@ -33,7 +35,6 @@
3335
#include "models/image_model.h"
3436
#include "models/input_data.h"
3537
#include "models/internal_model_data.h"
36-
#include "models/jpeg_restoration_model.h"
3738
#include "models/results.h"
3839

3940
JPEGRestorationModel::JPEGRestorationModel(const std::string& modelFileName,

demos/common/cpp/monitors/include/monitors/cpu_monitor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#pragma once
66

77
#include <deque>
8+
#include <iosfwd>
89
#include <memory>
910
#include <vector>
1011

@@ -24,5 +25,6 @@ class CpuMonitor {
2425
std::vector<double> cpuLoadSum;
2526
std::deque<std::vector<double>> cpuLoadHistory;
2627
class PerformanceCounter;
28+
2729
std::unique_ptr<PerformanceCounter> performanceCounter;
2830
};

demos/common/cpp/monitors/include/monitors/memory_monitor.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
#pragma once
66

77
#include <deque>
8+
#include <iosfwd>
89
#include <memory>
10+
#include <utility>
911

1012
class MemoryMonitor {
1113
public:
@@ -15,12 +17,13 @@ class MemoryMonitor {
1517
std::size_t getHistorySize() const;
1618
void collectData();
1719
std::deque<std::pair<double, double>> getLastHistory() const;
18-
double getMeanMem() const; // in GiB
20+
double getMeanMem() const; // in GiB
1921
double getMeanSwap() const;
2022
double getMaxMem() const;
2123
double getMaxSwap() const;
2224
double getMemTotal() const;
23-
double getMaxMemTotal() const; // a system may have hotpluggable memory
25+
double getMaxMemTotal() const; // a system may have hotpluggable memory
26+
2427
private:
2528
unsigned samplesNumber;
2629
std::size_t historySize;
@@ -30,5 +33,6 @@ class MemoryMonitor {
3033
double maxMemTotal;
3134
std::deque<std::pair<double, double>> memSwapUsageHistory;
3235
class PerformanceCounter;
36+
3337
std::unique_ptr<PerformanceCounter> performanceCounter;
3438
};

demos/common/cpp/monitors/include/monitors/presenter.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,37 @@
55
#pragma once
66

77
#include <chrono>
8-
#include <map>
98
#include <ostream>
109
#include <set>
10+
#include <string>
11+
#include <vector>
1112

12-
#include <opencv2/imgproc.hpp>
13+
#include <opencv2/core.hpp>
1314

1415
#include "cpu_monitor.h"
1516
#include "memory_monitor.h"
1617

17-
enum class MonitorType{CpuAverage, DistributionCpu, Memory};
18+
enum class MonitorType { CpuAverage, DistributionCpu, Memory };
1819

1920
class Presenter {
2021
public:
2122
explicit Presenter(std::set<MonitorType> enabledMonitors = {},
22-
int yPos = 20,
23-
cv::Size graphSize = {150, 60},
24-
std::size_t historySize = 20);
23+
int yPos = 20,
24+
cv::Size graphSize = {150, 60},
25+
std::size_t historySize = 20);
2526
explicit Presenter(const std::string& keys,
26-
int yPos = 20,
27-
cv::Size graphSize = {150, 60},
28-
std::size_t historySize = 20);
27+
int yPos = 20,
28+
cv::Size graphSize = {150, 60},
29+
std::size_t historySize = 20);
2930
void addRemoveMonitor(MonitorType monitor);
30-
void handleKey(int key); // handles C, D, M, H keys
31+
void handleKey(int key); // handles C, D, M, H keys
3132
void drawGraphs(const cv::Mat& frame);
3233
std::vector<std::string> reportMeans() const;
3334

3435
const int yPos;
3536
const cv::Size graphSize;
3637
const int graphPadding;
38+
3739
private:
3840
std::chrono::steady_clock::time_point prevTimeStamp;
3941
std::size_t historySize;

demos/common/cpp/monitors/src/cpu_monitor.cpp

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,25 @@
55
#include "monitors/cpu_monitor.h"
66

77
#include <algorithm>
8-
#ifdef _WIN32
9-
#include "query_wrapper.h"
8+
#include <stdexcept>
109
#include <string>
11-
#include <system_error>
12-
#include <PdhMsg.h>
13-
#include <Windows.h>
10+
#ifdef _WIN32
11+
// Windows.h must come first
12+
// clang-format off
13+
# include <Windows.h>
14+
# include <PdhMsg.h>
15+
// clang-format on
16+
# include <string>
17+
# include <system_error>
18+
19+
# include "query_wrapper.h"
1420

1521
namespace {
1622
const std::size_t nCores = []() {
17-
SYSTEM_INFO sysinfo;
18-
GetSystemInfo(&sysinfo);
19-
return sysinfo.dwNumberOfProcessors;
20-
}();
23+
SYSTEM_INFO sysinfo;
24+
GetSystemInfo(&sysinfo);
25+
return sysinfo.dwNumberOfProcessors;
26+
}();
2127
}
2228

2329
class CpuMonitor::PerformanceCounter {
@@ -30,7 +36,7 @@ class CpuMonitor::PerformanceCounter {
3036
if (ERROR_SUCCESS != status) {
3137
throw std::system_error(status, std::system_category(), "PdhAddCounterW() failed");
3238
}
33-
status = PdhSetCounterScaleFactor(coreTimeCounters[i], -2); // scale counter to [0, 1]
39+
status = PdhSetCounterScaleFactor(coreTimeCounters[i], -2); // scale counter to [0, 1]
3440
if (ERROR_SUCCESS != status) {
3541
throw std::system_error(status, std::system_category(), "PdhSetCounterScaleFactor() failed");
3642
}
@@ -51,12 +57,13 @@ class CpuMonitor::PerformanceCounter {
5157
PDH_FMT_COUNTERVALUE displayValue;
5258
std::vector<double> cpuLoad(coreTimeCounters.size());
5359
for (std::size_t i = 0; i < coreTimeCounters.size(); ++i) {
54-
status = PdhGetFormattedCounterValue(coreTimeCounters[i], PDH_FMT_DOUBLE, NULL,
55-
&displayValue);
60+
status = PdhGetFormattedCounterValue(coreTimeCounters[i], PDH_FMT_DOUBLE, NULL, &displayValue);
5661
switch (status) {
57-
case ERROR_SUCCESS: break;
62+
case ERROR_SUCCESS:
63+
break;
5864
// PdhGetFormattedCounterValue() can sometimes return PDH_CALC_NEGATIVE_DENOMINATOR for some reason
59-
case PDH_CALC_NEGATIVE_DENOMINATOR: return {};
65+
case PDH_CALC_NEGATIVE_DENOMINATOR:
66+
return {};
6067
default:
6168
throw std::system_error(status, std::system_category(), "PdhGetFormattedCounterValue() failed");
6269
}
@@ -75,11 +82,11 @@ class CpuMonitor::PerformanceCounter {
7582
};
7683

7784
#elif __linux__
78-
#include <chrono>
79-
#include <regex>
80-
#include <utility>
81-
#include <fstream>
82-
#include <unistd.h>
85+
# include <unistd.h>
86+
# include <chrono>
87+
# include <fstream>
88+
# include <regex>
89+
# include <utility>
8390

8491
namespace {
8592
const long clockTicks = sysconf(_SC_CLK_TCK);
@@ -92,17 +99,16 @@ std::vector<unsigned long> getIdleCpuStat() {
9299
std::string line;
93100
std::smatch match;
94101
std::regex coreJiffies("^cpu(\\d+)\\s+"
95-
"(\\d+)\\s+"
96-
"(\\d+)\\s+"
97-
"(\\d+)\\s+"
98-
"(\\d+)\\s+" // idle
99-
"(\\d+)"); // iowait
102+
"(\\d+)\\s+"
103+
"(\\d+)\\s+"
104+
"(\\d+)\\s+"
105+
"(\\d+)\\s+" // idle
106+
"(\\d+)"); // iowait
100107

101108
while (std::getline(procStat, line)) {
102109
if (std::regex_search(line, match, coreJiffies)) {
103110
// it doesn't handle overflow of sum and overflows of /proc/stat values
104-
unsigned long idleInfo = stoul(match[5]) + stoul(match[6]),
105-
coreId = stoul(match[1]);
111+
unsigned long idleInfo = stoul(match[5]) + stoul(match[6]), coreId = stoul(match[1]);
106112
if (nCores <= coreId) {
107113
throw std::runtime_error("The number of cores has changed");
108114
}
@@ -111,7 +117,7 @@ std::vector<unsigned long> getIdleCpuStat() {
111117
}
112118
return idleCpuStat;
113119
}
114-
}
120+
} // namespace
115121

116122
class CpuMonitor::PerformanceCounter {
117123
public:
@@ -127,15 +133,16 @@ class CpuMonitor::PerformanceCounter {
127133
for (std::size_t i = 0; i < idleCpuStat.size(); ++i) {
128134
double idleDiff = idleCpuStat[i] - prevIdleCpuStat[i];
129135
typedef std::chrono::duration<double, std::chrono::seconds::period> Sec;
130-
cpuLoad[i] = 1.0
131-
- idleDiff / clockTicks / std::chrono::duration_cast<Sec>(timePoint - prevTimePoint).count();
136+
cpuLoad[i] =
137+
1.0 - idleDiff / clockTicks / std::chrono::duration_cast<Sec>(timePoint - prevTimePoint).count();
132138
}
133139
prevIdleCpuStat = std::move(idleCpuStat);
134140
prevTimePoint = timePoint;
135141
return cpuLoad;
136142
}
137143
return {};
138144
}
145+
139146
private:
140147
std::vector<unsigned long> prevIdleCpuStat;
141148
std::chrono::steady_clock::time_point prevTimePoint;
@@ -149,14 +156,13 @@ const std::size_t nCores{0};
149156

150157
class CpuMonitor::PerformanceCounter {
151158
public:
152-
std::vector<double> getCpuLoad() {return {};};
159+
std::vector<double> getCpuLoad() {
160+
return {};
161+
}
153162
};
154163
#endif
155164

156-
CpuMonitor::CpuMonitor() :
157-
samplesNumber{0},
158-
historySize{0},
159-
cpuLoadSum(nCores, 0) {}
165+
CpuMonitor::CpuMonitor() : samplesNumber{0}, historySize{0}, cpuLoadSum(nCores, 0) {}
160166

161167
// PerformanceCounter is incomplete in header and destructor can't be defined implicitly
162168
CpuMonitor::~CpuMonitor() = default;

0 commit comments

Comments
 (0)