data: log storage stats after parsing
This commit is contained in:
@@ -85,6 +85,8 @@ void Application::saveProject(const std::string& projectSettingsFilePath)
|
||||
|
||||
void Application::handleMessage(MessageFinishedParsing* message)
|
||||
{
|
||||
m_project->logStats();
|
||||
|
||||
if (message->errorCount > 0)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -120,6 +120,11 @@ void Project::parseCode()
|
||||
));
|
||||
}
|
||||
|
||||
void Project::logStats() const
|
||||
{
|
||||
m_storage->logStats();
|
||||
}
|
||||
|
||||
void Project::createFileManager()
|
||||
{
|
||||
std::shared_ptr<ProjectSettings> projSettings = ProjectSettings::getInstance();
|
||||
|
||||
@@ -26,6 +26,8 @@ public:
|
||||
void clearStorage();
|
||||
void parseCode();
|
||||
|
||||
void logStats() const;
|
||||
|
||||
private:
|
||||
Project(StorageAccessProxy* storageAccessProxy);
|
||||
Project(const Project&);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "data/Storage.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/utilityString.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
@@ -144,6 +146,27 @@ void Storage::logIndex() const
|
||||
LOG_INFO_STREAM(<< '\n' << m_tokenIndex);
|
||||
}
|
||||
|
||||
void Storage::logStats() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ss << "\nGraph:\n";
|
||||
ss << "\t" << m_graph.getNodeCount() << " Nodes\n";
|
||||
ss << "\t" << m_graph.getEdgeCount() << " Edges\n";
|
||||
|
||||
ss << "\nSearch:\n";
|
||||
ss << "\t" << m_tokenIndex.getCharCount() << " Characters\n";
|
||||
ss << "\t" << m_tokenIndex.getWordCount() << " Words\n";
|
||||
ss << "\t" << m_tokenIndex.getNodeCount() << " SearchNodes\n";
|
||||
|
||||
ss << "\nCode:\n";
|
||||
ss << "\t" << m_locationCollection.getTokenLocationCount() << " Locations\n";
|
||||
ss << "\t" << m_locationCollection.getTokenLocationLineCount() << " Lines\n";
|
||||
ss << "\t" << m_locationCollection.getTokenLocationFileCount() << " Files\n";
|
||||
|
||||
LOG_INFO(ss.str());
|
||||
}
|
||||
|
||||
void Storage::onError(const ParseLocation& location, const std::string& message)
|
||||
{
|
||||
log("ERROR", message, location);
|
||||
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
void logGraph() const;
|
||||
void logLocations() const;
|
||||
void logIndex() const;
|
||||
void logStats() const;
|
||||
|
||||
// ParserClient implementation
|
||||
virtual void onError(const ParseLocation& location, const std::string& message);
|
||||
|
||||
@@ -27,6 +27,18 @@ size_t TokenLocationCollection::getTokenLocationFileCount() const
|
||||
return m_files.size();
|
||||
}
|
||||
|
||||
size_t TokenLocationCollection::getTokenLocationLineCount() const
|
||||
{
|
||||
size_t count = 0;
|
||||
|
||||
for (const TokenLocationFilePairType& file : m_files)
|
||||
{
|
||||
count += file.second->getTokenLocationLineCount();
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
const std::map<Id, TokenLocation*>& TokenLocationCollection::getTokenLocations() const
|
||||
{
|
||||
return m_locations;
|
||||
|
||||
@@ -26,6 +26,8 @@ public:
|
||||
const TokenLocationFileMapType& getTokenLocationFiles() const;
|
||||
size_t getTokenLocationFileCount() const;
|
||||
|
||||
size_t getTokenLocationLineCount() const;
|
||||
|
||||
const std::map<Id, TokenLocation*>& getTokenLocations() const;
|
||||
size_t getTokenLocationCount() const;
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ SearchIndex::~SearchIndex()
|
||||
void SearchIndex::clear()
|
||||
{
|
||||
m_root.m_nodes.clear();
|
||||
m_dictionary.clear();
|
||||
}
|
||||
|
||||
size_t SearchIndex::getNodeCount() const
|
||||
@@ -41,6 +42,16 @@ size_t SearchIndex::getNodeCount() const
|
||||
return m_root.getNodeCount() - 1;
|
||||
}
|
||||
|
||||
size_t SearchIndex::getCharCount() const
|
||||
{
|
||||
return m_dictionary.getCharCount();
|
||||
}
|
||||
|
||||
size_t SearchIndex::getWordCount() const
|
||||
{
|
||||
return m_dictionary.getWordCount();
|
||||
}
|
||||
|
||||
Id SearchIndex::getWordId(const std::string& word)
|
||||
{
|
||||
return m_dictionary.getWordId(word);
|
||||
|
||||
@@ -22,6 +22,8 @@ public:
|
||||
void clear();
|
||||
|
||||
size_t getNodeCount() const;
|
||||
size_t getCharCount() const;
|
||||
size_t getWordCount() const;
|
||||
|
||||
Id getWordId(const std::string& word);
|
||||
const std::string& getWord(Id wordId) const;
|
||||
|
||||
@@ -13,6 +13,24 @@ Dictionary::~Dictionary()
|
||||
void Dictionary::clear()
|
||||
{
|
||||
m_words.clear();
|
||||
m_ids.clear();
|
||||
}
|
||||
|
||||
size_t Dictionary::getCharCount() const
|
||||
{
|
||||
size_t count = 0;
|
||||
|
||||
for (const std::pair<Id, std::string>& p : m_words)
|
||||
{
|
||||
count += p.second.size();
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
size_t Dictionary::getWordCount() const
|
||||
{
|
||||
return m_words.size();
|
||||
}
|
||||
|
||||
Id Dictionary::getWordId(const std::string& word)
|
||||
|
||||
@@ -17,6 +17,9 @@ public:
|
||||
|
||||
void clear();
|
||||
|
||||
size_t getCharCount() const;
|
||||
size_t getWordCount() const;
|
||||
|
||||
Id getWordId(const std::string& word);
|
||||
Id getWordIdConst(const std::string& word) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user