mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-25 09:05:10 +00:00
.
This commit is contained in:
parent
eb7d0951ce
commit
a58a38c32d
@ -189,7 +189,6 @@ target_sources(ccls PRIVATE
|
|||||||
src/include_complete.cc
|
src/include_complete.cc
|
||||||
src/method.cc
|
src/method.cc
|
||||||
src/lex_utils.cc
|
src/lex_utils.cc
|
||||||
src/lsp_diagnostic.cc
|
|
||||||
src/lsp.cc
|
src/lsp.cc
|
||||||
src/match.cc
|
src/match.cc
|
||||||
src/message_handler.cc
|
src/message_handler.cc
|
||||||
|
@ -491,30 +491,6 @@ bool IndexMain_DoCreateIndexUpdate(TimestampManager* timestamp_manager) {
|
|||||||
response->current->file->last_modification_time);
|
response->current->file->last_modification_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if false
|
|
||||||
#define PRINT_SECTION(name) \
|
|
||||||
if (response->perf.name) { \
|
|
||||||
total += response->perf.name; \
|
|
||||||
output << " " << #name << ": " << FormatMicroseconds(response->perf.name); \
|
|
||||||
}
|
|
||||||
std::stringstream output;
|
|
||||||
long long total = 0;
|
|
||||||
output << "[perf]";
|
|
||||||
PRINT_SECTION(index_parse);
|
|
||||||
PRINT_SECTION(index_build);
|
|
||||||
PRINT_SECTION(index_save_to_disk);
|
|
||||||
PRINT_SECTION(index_load_cached);
|
|
||||||
PRINT_SECTION(querydb_id_map);
|
|
||||||
PRINT_SECTION(index_make_delta);
|
|
||||||
output << "\n total: " << FormatMicroseconds(total);
|
|
||||||
output << " path: " << response->current_index->path;
|
|
||||||
LOG_S(INFO) << output.rdbuf();
|
|
||||||
#undef PRINT_SECTION
|
|
||||||
|
|
||||||
if (response->is_interactive)
|
|
||||||
LOG_S(INFO) << "Applying IndexUpdate" << std::endl << update.ToString();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Index_OnIndexed reply(std::move(update), response->perf);
|
Index_OnIndexed reply(std::move(update), response->perf);
|
||||||
queue->on_indexed.PushBack(std::move(reply), response->is_interactive);
|
queue->on_indexed.PushBack(std::move(reply), response->is_interactive);
|
||||||
}
|
}
|
||||||
@ -551,13 +527,7 @@ bool IndexMergeIndexUpdates() {
|
|||||||
if (!to_join)
|
if (!to_join)
|
||||||
break;
|
break;
|
||||||
did_merge = true;
|
did_merge = true;
|
||||||
// Timer time;
|
|
||||||
root->update.Merge(std::move(to_join->update));
|
root->update.Merge(std::move(to_join->update));
|
||||||
// time.ResetAndPrint("Joined querydb updates for files: " +
|
|
||||||
// StringJoinMap(root->update.files_def_update,
|
|
||||||
//[](const QueryFile::DefUpdate& update) {
|
|
||||||
// return update.path;
|
|
||||||
//}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
queue->on_indexed.PushFront(std::move(*root));
|
queue->on_indexed.PushFront(std::move(*root));
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
#include "lsp_diagnostic.h"
|
|
||||||
|
|
||||||
#include "match.h"
|
|
||||||
#include "queue_manager.h"
|
|
||||||
#include "working_files.h"
|
|
@ -165,7 +165,7 @@ void FilterAndSortCompletionResponse(
|
|||||||
if (!enable)
|
if (!enable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ScopedPerfTimer timer("FilterAndSortCompletionResponse");
|
ScopedPerfTimer timer{"FilterAndSortCompletionResponse"};
|
||||||
|
|
||||||
// Used to inject more completions.
|
// Used to inject more completions.
|
||||||
#if false
|
#if false
|
||||||
|
71
src/test.cc
71
src/test.cc
@ -23,11 +23,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Write(const std::vector<std::string>& strs) {
|
|
||||||
for (const std::string& str : strs)
|
|
||||||
std::cout << str << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ToString(const rapidjson::Document& document) {
|
std::string ToString(const rapidjson::Document& document) {
|
||||||
rapidjson::StringBuffer buffer;
|
rapidjson::StringBuffer buffer;
|
||||||
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buffer);
|
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buffer);
|
||||||
@ -46,41 +41,6 @@ void ParseTestExpectation(
|
|||||||
TextReplacer* replacer,
|
TextReplacer* replacer,
|
||||||
std::vector<std::string>* flags,
|
std::vector<std::string>* flags,
|
||||||
std::unordered_map<std::string, std::string>* output_sections) {
|
std::unordered_map<std::string, std::string>* output_sections) {
|
||||||
#if false
|
|
||||||
#include "bar.h"
|
|
||||||
|
|
||||||
void foo();
|
|
||||||
|
|
||||||
/*
|
|
||||||
// DOCS for TEXT_REPLACE:
|
|
||||||
// Each line under TEXT_REPLACE is a replacement, ie, the two entries will be
|
|
||||||
// considered equivalent. This is useful for USRs which vary across files.
|
|
||||||
|
|
||||||
// DOCS for EXTRA_FLAGS:
|
|
||||||
// Additional flags to pass to clang.
|
|
||||||
|
|
||||||
// DOCS for OUTPUT:
|
|
||||||
// If no name is given assume to be this file name. If there is not an output
|
|
||||||
// section for a file it is not checked.
|
|
||||||
|
|
||||||
TEXT_REPLACE:
|
|
||||||
foo <===> bar
|
|
||||||
one <===> two
|
|
||||||
|
|
||||||
EXTRA_FLAGS:
|
|
||||||
-std=c++14
|
|
||||||
|
|
||||||
OUTPUT:
|
|
||||||
{}
|
|
||||||
|
|
||||||
OUTPUT: bar.cc
|
|
||||||
{}
|
|
||||||
|
|
||||||
OUTPUT: bar.h
|
|
||||||
{}
|
|
||||||
*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Scan for EXTRA_FLAGS:
|
// Scan for EXTRA_FLAGS:
|
||||||
{
|
{
|
||||||
bool in_output = false;
|
bool in_output = false;
|
||||||
@ -201,34 +161,6 @@ void DiffDocuments(std::string path,
|
|||||||
<< "):" << std::endl;
|
<< "):" << std::endl;
|
||||||
std::cout << joined_actual_output << std::endl;
|
std::cout << joined_actual_output << std::endl;
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
int max_diff = 5;
|
|
||||||
|
|
||||||
size_t len = std::min(actual_output.size(), expected_output.size());
|
|
||||||
for (size_t i = 0; i < len; ++i) {
|
|
||||||
if (actual_output[i] != expected_output[i]) {
|
|
||||||
if (--max_diff < 0) {
|
|
||||||
std::cout << "(... more lines may differ ...)" << std::endl;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << "Line " << i << " differs:" << std::endl;
|
|
||||||
std::cout << " expected: " << expected_output[i] << std::endl;
|
|
||||||
std::cout << " actual: " << actual_output[i] << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (actual_output.size() > len) {
|
|
||||||
std::cout << "Additional output in actual:" << std::endl;
|
|
||||||
for (size_t i = len; i < actual_output.size(); ++i)
|
|
||||||
std::cout << " " << actual_output[i] << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (expected_output.size() > len) {
|
|
||||||
std::cout << "Additional output in expected:" << std::endl;
|
|
||||||
for (size_t i = len; i < expected_output.size(); ++i)
|
|
||||||
std::cout << " " << expected_output[i] << std::endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerifySerializeToFrom(IndexFile* file) {
|
void VerifySerializeToFrom(IndexFile* file) {
|
||||||
@ -322,9 +254,6 @@ bool RunIndexTests(const std::string& filter_path, bool enable_update) {
|
|||||||
bool had_extra_flags = !flags.empty();
|
bool had_extra_flags = !flags.empty();
|
||||||
if (!AnyStartsWith(flags, "-x"))
|
if (!AnyStartsWith(flags, "-x"))
|
||||||
flags.push_back("-xc++");
|
flags.push_back("-xc++");
|
||||||
// Use c++14 by default, because MSVC STL is written assuming that.
|
|
||||||
if (!AnyStartsWith(flags, "-std"))
|
|
||||||
flags.push_back("-std=c++14");
|
|
||||||
flags.push_back("-resource-dir=" + GetDefaultResourceDirectory());
|
flags.push_back("-resource-dir=" + GetDefaultResourceDirectory());
|
||||||
if (had_extra_flags) {
|
if (had_extra_flags) {
|
||||||
std::cout << "For " << path << std::endl;
|
std::cout << "For " << path << std::endl;
|
||||||
|
19
src/timer.cc
19
src/timer.cc
@ -8,13 +8,9 @@ Timer::Timer() {
|
|||||||
|
|
||||||
long long Timer::ElapsedMicroseconds() const {
|
long long Timer::ElapsedMicroseconds() const {
|
||||||
std::chrono::time_point<Clock> end = Clock::now();
|
std::chrono::time_point<Clock> end = Clock::now();
|
||||||
long long elapsed = elapsed_;
|
return elapsed_ +
|
||||||
if (start_.has_value()) {
|
std::chrono::duration_cast<std::chrono::microseconds>(end - start_)
|
||||||
elapsed +=
|
.count();
|
||||||
std::chrono::duration_cast<std::chrono::microseconds>(end - *start_)
|
|
||||||
.count();
|
|
||||||
}
|
|
||||||
return elapsed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long long Timer::ElapsedMicrosecondsAndReset() {
|
long long Timer::ElapsedMicrosecondsAndReset() {
|
||||||
@ -38,25 +34,18 @@ void Timer::ResetAndPrint(const std::string& message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Timer::Pause() {
|
void Timer::Pause() {
|
||||||
assert(start_.has_value());
|
|
||||||
|
|
||||||
std::chrono::time_point<Clock> end = Clock::now();
|
std::chrono::time_point<Clock> end = Clock::now();
|
||||||
long long elapsed =
|
long long elapsed =
|
||||||
std::chrono::duration_cast<std::chrono::microseconds>(end - *start_)
|
std::chrono::duration_cast<std::chrono::microseconds>(end - start_)
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
elapsed_ += elapsed;
|
elapsed_ += elapsed;
|
||||||
start_ = std::nullopt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Timer::Resume() {
|
void Timer::Resume() {
|
||||||
assert(!start_.has_value());
|
|
||||||
start_ = Clock::now();
|
start_ = Clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedPerfTimer::ScopedPerfTimer(const std::string& message)
|
|
||||||
: message_(message) {}
|
|
||||||
|
|
||||||
ScopedPerfTimer::~ScopedPerfTimer() {
|
ScopedPerfTimer::~ScopedPerfTimer() {
|
||||||
timer_.ResetAndPrint(message_);
|
timer_.ResetAndPrint(message_);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <optional>
|
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -25,15 +23,14 @@ struct Timer {
|
|||||||
void Resume();
|
void Resume();
|
||||||
|
|
||||||
// Raw start time.
|
// Raw start time.
|
||||||
std::optional<std::chrono::time_point<Clock>> start_;
|
std::chrono::time_point<Clock> start_;
|
||||||
// Elapsed time.
|
// Elapsed time.
|
||||||
long long elapsed_ = 0;
|
long long elapsed_;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ScopedPerfTimer {
|
struct ScopedPerfTimer {
|
||||||
ScopedPerfTimer(const std::string& message);
|
|
||||||
~ScopedPerfTimer();
|
~ScopedPerfTimer();
|
||||||
|
|
||||||
Timer timer_;
|
|
||||||
std::string message_;
|
std::string message_;
|
||||||
|
Timer timer_;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user