Format all C++ and Java code via clang-format

Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
Konstantin Pastbin
2025-08-17 14:32:37 +07:00
parent 9f0290c0ec
commit bfffa1fff4
2169 changed files with 56441 additions and 64188 deletions

View File

@@ -24,7 +24,7 @@ void Result::CalcMetrics()
sort(m_time.begin(), m_time.end());
m_max = m_time.back();
m_med = m_time[m_time.size()/2];
m_med = m_time[m_time.size() / 2];
m_all = accumulate(m_time.begin(), m_time.end(), 0.0);
m_avg = m_all / m_time.size();
@@ -36,7 +36,7 @@ void Result::CalcMetrics()
void AllResult::Print()
{
//m_reading.PrintAllTimes();
// m_reading.PrintAllTimes();
m_reading.CalcMetrics();
if (m_all < 0.0)
@@ -45,12 +45,10 @@ void AllResult::Print()
{
cout << fixed << setprecision(10);
size_t const count = 1000;
cout << "FRAME*1000[ median:" << m_reading.m_med * count <<
" avg:" << m_reading.m_avg * count <<
" max:" << m_reading.m_max * count << " ] ";
cout << "TOTAL[ idx:" << m_all - m_reading.m_all <<
" decoding:" << m_reading.m_all <<
" summ:" << m_all << " ]" << endl;
cout << "FRAME*1000[ median:" << m_reading.m_med * count << " avg:" << m_reading.m_avg * count
<< " max:" << m_reading.m_max * count << " ] ";
cout << "TOTAL[ idx:" << m_all - m_reading.m_all << " decoding:" << m_reading.m_all << " summ:" << m_all << " ]"
<< endl;
}
}
} // namespace bench

View File

@@ -6,43 +6,37 @@
namespace bench
{
class Result
{
public:
void Add(double t)
{
m_time.push_back(t);
}
class Result
{
public:
void Add(double t) { m_time.push_back(t); }
void Add(Result const & r)
{
m_time.insert(m_time.end(), r.m_time.begin(), r.m_time.end());
}
void Add(Result const & r) { m_time.insert(m_time.end(), r.m_time.begin(), r.m_time.end()); }
void PrintAllTimes();
void CalcMetrics();
void PrintAllTimes();
void CalcMetrics();
double m_all = 0.0;
double m_max = 0.0;
double m_avg = 0.0;
double m_med = 0.0;
double m_all = 0.0;
double m_max = 0.0;
double m_avg = 0.0;
double m_med = 0.0;
private:
std::vector<double> m_time;
};
private:
std::vector<double> m_time;
};
class AllResult
{
public:
AllResult() = default;
class AllResult
{
public:
AllResult() = default;
void Add(double t) { m_all += t; }
void Print();
void Add(double t) { m_all += t; }
void Print();
Result m_reading;
double m_all = 0.0;
};
Result m_reading;
double m_all = 0.0;
};
/// @param[in] count number of times to run benchmark
void RunFeaturesLoadingBenchmark(std::string filePath, std::pair<int, int> scaleR, AllResult & res);
/// @param[in] count number of times to run benchmark
void RunFeaturesLoadingBenchmark(std::string filePath, std::pair<int, int> scaleR, AllResult & res);
} // namespace bench

View File

@@ -20,84 +20,84 @@ namespace bench
{
namespace
{
class Accumulator
{
public:
explicit Accumulator(Result & res) : m_res(res) {}
class Accumulator
{
public:
explicit Accumulator(Result & res) : m_res(res) {}
void Reset(int scale)
void Reset(int scale)
{
m_scale = scale;
m_count = 0;
}
bool IsEmpty() const { return m_count == 0; }
void operator()(FeatureType & ft)
{
++m_count;
m_timer.Reset();
drule::KeysT keys;
UNUSED_VALUE(feature::GetDrawRule(feature::TypesHolder(ft), m_scale, keys));
if (!keys.empty())
{
m_scale = scale;
m_count = 0;
// Call this function to load feature's inner data and geometry.
UNUSED_VALUE(ft.IsEmptyGeometry(m_scale));
}
bool IsEmpty() const { return m_count == 0; }
m_res.Add(m_timer.ElapsedSeconds());
}
void operator()(FeatureType & ft)
private:
base::Timer m_timer;
size_t m_count = 0;
Result & m_res;
int m_scale = 0;
};
void RunBenchmark(FeaturesFetcher const & src, m2::RectD const & rect, pair<int, int> const & scaleRange,
AllResult & res)
{
ASSERT_LESS_OR_EQUAL(scaleRange.first, scaleRange.second, ());
vector<m2::RectD> rects;
rects.push_back(rect);
Accumulator acc(res.m_reading);
while (!rects.empty())
{
m2::RectD const r = rects.back();
rects.pop_back();
bool doDivide = true;
int const scale = scales::GetScaleLevel(r);
if (scale >= scaleRange.first)
{
++m_count;
acc.Reset(scale);
m_timer.Reset();
base::Timer timer;
src.ForEachFeature(r, acc, scale);
res.Add(timer.ElapsedSeconds());
drule::KeysT keys;
UNUSED_VALUE(feature::GetDrawRule(feature::TypesHolder(ft), m_scale, keys));
if (!keys.empty())
{
// Call this function to load feature's inner data and geometry.
UNUSED_VALUE(ft.IsEmptyGeometry(m_scale));
}
m_res.Add(m_timer.ElapsedSeconds());
doDivide = !acc.IsEmpty();
}
private:
base::Timer m_timer;
size_t m_count = 0;
Result & m_res;
int m_scale = 0;
};
void RunBenchmark(FeaturesFetcher const & src, m2::RectD const & rect,
pair<int, int> const & scaleRange, AllResult & res)
{
ASSERT_LESS_OR_EQUAL(scaleRange.first, scaleRange.second, ());
vector<m2::RectD> rects;
rects.push_back(rect);
Accumulator acc(res.m_reading);
while (!rects.empty())
if (doDivide && scale < scaleRange.second)
{
m2::RectD const r = rects.back();
rects.pop_back();
bool doDivide = true;
int const scale = scales::GetScaleLevel(r);
if (scale >= scaleRange.first)
{
acc.Reset(scale);
base::Timer timer;
src.ForEachFeature(r, acc, scale);
res.Add(timer.ElapsedSeconds());
doDivide = !acc.IsEmpty();
}
if (doDivide && scale < scaleRange.second)
{
m2::RectD r1, r2;
r.DivideByGreaterSize(r1, r2);
rects.push_back(r1);
rects.push_back(r2);
}
m2::RectD r1, r2;
r.DivideByGreaterSize(r1, r2);
rects.push_back(r1);
rects.push_back(r2);
}
}
}
} // namespace
void RunFeaturesLoadingBenchmark(string fileName, pair<int, int> scaleRange, AllResult & res)
{