[PATCH 07/11] kernel-shark-qt: Optimize the search in a case of a small data-set

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Parallelizing the search (map-reduce) and showing the progress make
sense only in the case of very big data-sets. If the data-set is
small we do not want to have the overhead added by the update of
the progress bar. This overhead turns to be not so small (~1s. on
my laptop).

Signed-off-by: Yordan Karadzhov <ykaradzhov@xxxxxxxxxx>
---
 kernel-shark-qt/src/KsTraceViewer.cpp | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/kernel-shark-qt/src/KsTraceViewer.cpp b/kernel-shark-qt/src/KsTraceViewer.cpp
index 1f96234..64c9fb7 100644
--- a/kernel-shark-qt/src/KsTraceViewer.cpp
+++ b/kernel-shark-qt/src/KsTraceViewer.cpp
@@ -579,6 +579,12 @@ void KsTraceViewer::_resizeToContents()
 	_view.setColumnWidth(0, columnSize);
 }
 
+//! @cond Doxygen_Suppress
+
+#define KS_SEARCH_SHOW_PROGRESS_MIN 100000
+
+//! @endcond
+
 size_t KsTraceViewer::_searchItems(int column,
 				   const QString &searchText,
 				   condition_func cond)
@@ -588,7 +594,14 @@ size_t KsTraceViewer::_searchItems(int column,
 	_searchProgBar.show();
 	_pbAction->setVisible(true);
 
-	if (column == KsViewModel::TRACE_VIEW_COL_INFO ||
+	if (_proxyModel.rowCount({}) < KS_SEARCH_SHOW_PROGRESS_MIN) {
+		/*
+		 * This is a small data-set. Do a single-threaded search
+		 * without showing the progress.
+		 */
+		_proxyModel.search(column, searchText, cond, &_matchList,
+				   nullptr, nullptr);
+	} else if (column == KsViewModel::TRACE_VIEW_COL_INFO ||
 	    column == KsViewModel::TRACE_VIEW_COL_LAT) {
 		_searchStopAction->setVisible(true);
 		_proxyModel.search(column, searchText, cond, &_matchList,
-- 
2.17.1





[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux