Add ScopedPerfTimer

This commit is contained in:
Jacob Dufault 2018-01-12 10:01:35 -08:00
parent de5e8eeeba
commit 71ae137393
4 changed files with 19 additions and 0 deletions

View File

@ -479,6 +479,7 @@ void CompletionQueryMain(ClangCompleteManager* completion_manager) {
// TODO: before emitting diagnostics check if we have another completion
// request and think about servicing that first, because it may be much
// faster than reparsing the document.
// TODO: have a separate thread for diagnostics?
timer.Reset();
session->tu =

View File

@ -3,6 +3,7 @@
#include "include_complete.h"
#include "message_handler.h"
#include "queue_manager.h"
#include "timer.h"
#include "working_files.h"
#include "lex_utils.h"
@ -101,6 +102,8 @@ char* tofixedbase64(T input, char* out) {
void SortAndFilterCompletionResponse(
Out_TextDocumentComplete* complete_response,
const std::string& complete_text) {
ScopedPerfTimer timer("SortAndFilterCompletionResponse");
// Used to inject more completions.
#if false
const size_t kNumIterations = 250;

View File

@ -55,3 +55,10 @@ void Timer::Resume() {
assert(!start_.has_value());
start_ = Clock::now();
}
ScopedPerfTimer::ScopedPerfTimer(const std::string& message) : message_(message) {}
ScopedPerfTimer::~ScopedPerfTimer() {
timer_.ResetAndPrint(message_);
}

View File

@ -29,3 +29,11 @@ struct Timer {
// Elapsed time.
long long elapsed_ = 0;
};
struct ScopedPerfTimer {
ScopedPerfTimer(const std::string& message);
~ScopedPerfTimer();
Timer timer_;
std::string message_;
};