mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-11-04 06:15:20 +00:00 
			
		
		
		
	Add ScopedPerfTimer
This commit is contained in:
		
							parent
							
								
									de5e8eeeba
								
							
						
					
					
						commit
						71ae137393
					
				@ -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 =
 | 
			
		||||
 | 
			
		||||
@ -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;
 | 
			
		||||
 | 
			
		||||
@ -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_);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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_;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user