Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Oct 24, 2019
1 parent eb7d095 commit a58a38c
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 129 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ target_sources(ccls PRIVATE
src/include_complete.cc
src/method.cc
src/lex_utils.cc
src/lsp_diagnostic.cc
src/lsp.cc
src/match.cc
src/message_handler.cc
Expand Down
30 changes: 0 additions & 30 deletions src/import_pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -491,30 +491,6 @@ bool IndexMain_DoCreateIndexUpdate(TimestampManager* timestamp_manager) {
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);
queue->on_indexed.PushBack(std::move(reply), response->is_interactive);
}
Expand Down Expand Up @@ -551,13 +527,7 @@ bool IndexMergeIndexUpdates() {
if (!to_join)
break;
did_merge = true;
// Timer time;
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));
Expand Down
5 changes: 0 additions & 5 deletions src/lsp_diagnostic.cc

This file was deleted.

2 changes: 1 addition & 1 deletion src/messages/text_document_completion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void FilterAndSortCompletionResponse(
if (!enable)
return;

ScopedPerfTimer timer("FilterAndSortCompletionResponse");
ScopedPerfTimer timer{"FilterAndSortCompletionResponse"};

// Used to inject more completions.
#if false
Expand Down
71 changes: 0 additions & 71 deletions src/test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
#include <unistd.h>
#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) {
rapidjson::StringBuffer buffer;
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buffer);
Expand All @@ -46,41 +41,6 @@ void ParseTestExpectation(
TextReplacer* replacer,
std::vector<std::string>* flags,
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:
{
bool in_output = false;
Expand Down Expand Up @@ -201,34 +161,6 @@ void DiffDocuments(std::string path,
<< "):" << std::endl;
std::cout << joined_actual_output << 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) {
Expand Down Expand Up @@ -322,9 +254,6 @@ bool RunIndexTests(const std::string& filter_path, bool enable_update) {
bool had_extra_flags = !flags.empty();
if (!AnyStartsWith(flags, "-x"))
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());
if (had_extra_flags) {
std::cout << "For " << path << std::endl;
Expand Down
19 changes: 4 additions & 15 deletions src/timer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ Timer::Timer() {

long long Timer::ElapsedMicroseconds() const {
std::chrono::time_point<Clock> end = Clock::now();
long long elapsed = elapsed_;
if (start_.has_value()) {
elapsed +=
std::chrono::duration_cast<std::chrono::microseconds>(end - *start_)
.count();
}
return elapsed;
return elapsed_ +
std::chrono::duration_cast<std::chrono::microseconds>(end - start_)
.count();
}

long long Timer::ElapsedMicrosecondsAndReset() {
Expand All @@ -38,25 +34,18 @@ void Timer::ResetAndPrint(const std::string& message) {
}

void Timer::Pause() {
assert(start_.has_value());

std::chrono::time_point<Clock> end = Clock::now();
long long elapsed =
std::chrono::duration_cast<std::chrono::microseconds>(end - *start_)
std::chrono::duration_cast<std::chrono::microseconds>(end - start_)
.count();

elapsed_ += elapsed;
start_ = std::nullopt;
}

void Timer::Resume() {
assert(!start_.has_value());
start_ = Clock::now();
}

ScopedPerfTimer::ScopedPerfTimer(const std::string& message)
: message_(message) {}

ScopedPerfTimer::~ScopedPerfTimer() {
timer_.ResetAndPrint(message_);
}
9 changes: 3 additions & 6 deletions src/timer.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

#include <optional>

#include <chrono>
#include <string>

Expand All @@ -25,15 +23,14 @@ struct Timer {
void Resume();

// Raw start time.
std::optional<std::chrono::time_point<Clock>> start_;
std::chrono::time_point<Clock> start_;
// Elapsed time.
long long elapsed_ = 0;
long long elapsed_;
};

struct ScopedPerfTimer {
ScopedPerfTimer(const std::string& message);
~ScopedPerfTimer();

Timer timer_;
std::string message_;
Timer timer_;
};

0 comments on commit a58a38c

Please sign in to comment.