MCPcopy Create free account
hub / github.com/KDE/kdevelop / testImportCache

Method testImportCache

kdevplatform/language/duchain/tests/test_duchain.cpp:993–1028  ·  view source on GitHub ↗

FIXME: this needs to be rewritten in order to remove dependencies on formerly run unit tests

Source from the content-addressed store, hash-verified

991
992///FIXME: this needs to be rewritten in order to remove dependencies on formerly run unit tests
993void TestDUChain::testImportCache()
994{
995 KDevelop::globalItemRepositoryRegistry().printAllStatistics();
996
997 KDevelop::RecursiveImportRepository::repository()->printStatistics();
998
999 //Analyze the whole existing import-cache
1000 //This is very expensive, since it involves loading all existing top-contexts
1001 uint topContextCount = DUChain::self()->newTopContextIndex();
1002
1003 uint analyzedCount = 0;
1004 uint totalImportCount = 0;
1005 uint naiveNodeCount = 0;
1006 QSet<uint> reachableNodes;
1007
1008 DUChainReadLocker lock(DUChain::lock());
1009 for (uint a = 0; a < topContextCount; ++a) {
1010 if (a % qMax(1u, topContextCount / 100) == 0) {
1011 qDebug() << "progress:" << (a * 100) / topContextCount;
1012 }
1013 TopDUContext* context = DUChain::self()->chainForIndex(a);
1014 if (context) {
1015 TopDUContext::IndexedRecursiveImports imports = context->recursiveImportIndices();
1016 ++analyzedCount;
1017 totalImportCount += imports.set().count();
1018 collectReachableNodes(reachableNodes, imports.setIndex());
1019 naiveNodeCount += collectNaiveNodeCount(imports.setIndex());
1020 }
1021 }
1022
1023 QVERIFY(analyzedCount);
1024 qDebug() << "average total count of imports:" << totalImportCount / analyzedCount;
1025 qDebug() << "count of reachable nodes:" << reachableNodes.size();
1026 qDebug() << "naive node-count:" << naiveNodeCount << "sharing compression factor:" <<
1027 (( float )reachableNodes.size()) / (( float )naiveNodeCount);
1028}
1029
1030#endif
1031

Callers

nothing calls this directly

Calls 9

collectReachableNodesFunction · 0.85
collectNaiveNodeCountFunction · 0.85
printAllStatisticsMethod · 0.80
newTopContextIndexMethod · 0.80
printStatisticsMethod · 0.45
countMethod · 0.45
setMethod · 0.45
setIndexMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected