Skip to content

Commit

Permalink
Add throttling for search progress updates
Browse files Browse the repository at this point in the history
  • Loading branch information
variar committed Aug 16, 2018
1 parent b7d4b28 commit 7763beb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/ui/src/crawlerwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "log.h"

#include <cassert>
#include <chrono>

#include <Qt>
#include <QApplication>
Expand Down Expand Up @@ -341,14 +342,23 @@ void CrawlerWidget::updateFilteredView( LinesCount nbMatches, int progress, Line
}
}

static auto lastUpdateTime = std::chrono::high_resolution_clock::now();

const auto currentUpdateTime = std::chrono::high_resolution_clock::now();
const auto timeSinceLastUpdate = currentUpdateTime - lastUpdateTime;
if ( progress > 0 && progress < 100 && timeSinceLastUpdate < std::chrono::milliseconds(250) ) {
LOG(logDEBUG) << "updateFilteredView skipped";
return;
}
lastUpdateTime = currentUpdateTime;

// If more (or less, e.g. come back to 0) matches have been found
if ( nbMatches != nbMatches_ ) {
nbMatches_ = nbMatches;

// Recompute the content of the filtered window.
filteredView->updateData();


// Update the match overview
overview_.updateData( logData_->getNbLine() );

Expand Down

0 comments on commit 7763beb

Please sign in to comment.