mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-11-04 06:15:20 +00:00 
			
		
		
		
	.
This commit is contained in:
		
							parent
							
								
									9aca6119ed
								
							
						
					
					
						commit
						d83be5adcc
					
				@ -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
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
  }
 | 
			
		||||
@ -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));
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  ScopedPerfTimer timer("FilterAndSortCompletionResponse");
 | 
			
		||||
  ScopedPerfTimer timer{"FilterAndSortCompletionResponse"};
 | 
			
		||||
 | 
			
		||||
// Used to inject more completions.
 | 
			
		||||
#if false
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										71
									
								
								src/test.cc
									
									
									
									
									
								
							
							
						
						
									
										71
									
								
								src/test.cc
									
									
									
									
									
								
							@ -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);
 | 
			
		||||
@ -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;
 | 
			
		||||
@ -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) {
 | 
			
		||||
@ -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;
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										19
									
								
								src/timer.cc
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								src/timer.cc
									
									
									
									
									
								
							@ -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() {
 | 
			
		||||
@ -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_);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,5 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <optional>
 | 
			
		||||
 | 
			
		||||
#include <chrono>
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
@ -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_;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user