Skip to content

Commit 73f8e72

Browse files
committed
Revert "Made the metric calculation parallel"
This reverts commit bc01a10.
1 parent bc01a10 commit 73f8e72

File tree

2 files changed

+31
-41
lines changed

2 files changed

+31
-41
lines changed

plugins/cpp_metrics/parser/include/cppmetricsparser/cppmetricsparser.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ class CppMetricsParser : public AbstractParser
198198
static const int functionMcCabePartitionMultiplier = 5;
199199
static const int functionBumpyRoadPartitionMultiplier = 5;
200200
static const int lackOfCohesionPartitionMultiplier = 25;
201-
static const int afferentCouplingPartitionMultiplier = 25;
202201
};
203202

204203
} // parser

plugins/cpp_metrics/parser/src/cppmetricsparser.cpp

Lines changed: 31 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -103,55 +103,46 @@ bool CppMetricsParser::cleanupDatabase()
103103

104104
void CppMetricsParser::afferentCouplingTypeLevel()
105105
{
106-
107-
// Calculate the cohesion metric for all types on parallel threads.
108-
parallelCalcMetric<model::AfferentRecordView>(
109-
"Afferent coupling",
110-
_threadCount * lackOfCohesionPartitionMultiplier, // number of jobs; adjust for granularity
111-
getFilterPathsQuery<model::AfferentRecordView>(),
112-
[&, this](const MetricsTasks<model::AfferentRecordView>& tasks)
106+
util::OdbTransaction{_ctx.db}([&,this]
113107
{
114-
util::OdbTransaction{_ctx.db}([&,this]
115-
{
116-
std::set<std::uint64_t> typesFound;
117-
std::unordered_map<std::uint64_t, int> typeFoundCnt;
118-
std::unordered_map<std::uint64_t,std::uint64_t> astNodeIdOfType;
108+
std::set<std::uint64_t> typesFound;
109+
std::unordered_map<std::uint64_t, int> typeFoundCnt;
110+
std::unordered_map<std::uint64_t,std::uint64_t> astNodeIdOfType;
119111

120-
for (const model::AfferentRecordView& type
121-
: _ctx.db->query<model::AfferentRecordView>())
112+
for (const model::AfferentRecordView& type
113+
: _ctx.db->query<model::AfferentRecordView>())
114+
{
115+
if (!cc::util::isRootedUnderAnyOf(_inputPaths, type.filePath))
122116
{
123-
if (!cc::util::isRootedUnderAnyOf(_inputPaths, type.filePath))
124-
{
125-
continue;
126-
}
127-
128-
typesFound.clear();
129-
for (const model::CppMemberType& member : _ctx.db->query<model::CppMemberType>(
130-
odb::query<cc::model::CppMemberType>::typeHash == type.entityHash &&
131-
odb::query<cc::model::CppMemberType>::kind == model::CppMemberType::Kind::Field))
132-
{
133-
typesFound.insert(member.memberTypeHash);
134-
}
135-
136-
astNodeIdOfType[type.typeHash] = type.astNodeId;
117+
continue;
118+
}
137119

138-
for (const auto& t : typesFound)
139-
{
140-
typeFoundCnt[t]++;
141-
}
120+
typesFound.clear();
121+
for (const model::CppMemberType& member : _ctx.db->query<model::CppMemberType>(
122+
odb::query<cc::model::CppMemberType>::typeHash == type.entityHash &&
123+
odb::query<cc::model::CppMemberType>::kind == model::CppMemberType::Kind::Field))
124+
{
125+
typesFound.insert(member.memberTypeHash);
142126
}
143127

144-
for (const auto& pair : typeFoundCnt)
128+
astNodeIdOfType[type.typeHash] = type.astNodeId;
129+
130+
for (const auto& t : typesFound)
145131
{
146-
model::CppAstNodeMetrics metric;
147-
metric.astNodeId = astNodeIdOfType[pair.first];
148-
metric.type = model::CppAstNodeMetrics::Type::AFFERENT_COUPLING;
149-
metric.value = pair.second;
150-
_ctx.db->persist(metric);
132+
typeFoundCnt[t]++;
151133
}
152-
134+
}
135+
136+
for (const auto& pair : typeFoundCnt)
137+
{
138+
model::CppAstNodeMetrics metric;
139+
metric.astNodeId = astNodeIdOfType[pair.first];
140+
metric.type = model::CppAstNodeMetrics::Type::AFFERENT_COUPLING;
141+
metric.value = pair.second;
142+
_ctx.db->persist(metric);
143+
}
144+
153145

154-
});
155146
});
156147
}
157148

0 commit comments

Comments
 (0)