diff mbox series

[v2,1/3] kernel-shark: Simplify the search methods in class KsTraceViewer

Message ID 20200504174342.24615-2-y.karadz@gmail.com (mailing list archive)
State Accepted
Commit de7eeb4775b89f617581a9841e943974f6e6509c
Delegated to: Steven Rostedt
Headers show
Series kernel-shark: Have "stop" button for multi-threaded searches | expand

Commit Message

Yordan Karadzhov May 4, 2020, 5:43 p.m. UTC
This patch defines two identical private methods for single-threaded
and multi-threaded search inside the data table. This is done as a
preparation for the following patch that will change the mechanism
of the multi-threaded search.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 kernel-shark/src/KsTraceViewer.cpp | 12 ++++++------
 kernel-shark/src/KsTraceViewer.hpp |  5 +++--
 2 files changed, 9 insertions(+), 8 deletions(-)

Comments

Steven Rostedt May 4, 2020, 6:49 p.m. UTC | #1
On Mon,  4 May 2020 20:43:40 +0300
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:

> +++ b/kernel-shark/src/KsTraceViewer.hpp
> @@ -132,8 +132,9 @@ private:
>  
>  	size_t _searchItems();
>  
> -	void _searchItemsMapReduce(int column, const QString &searchText,
> -				   search_condition_func cond);
> +	void _searchItemsST() {_proxyModel.search(&_searchFSM, &_matchList);}
> +
> +	void _searchItemsMT();
>  
>  	void _searchEditText(const QString &);

I'll pull this in as-is, but the above should definitely have comments
stating one is "Single threaded" and the other is  "Multi threaded",
otherwise who would know what they mean?

-- Steve
diff mbox series

Patch

diff --git a/kernel-shark/src/KsTraceViewer.cpp b/kernel-shark/src/KsTraceViewer.cpp
index c176cef..0694532 100644
--- a/kernel-shark/src/KsTraceViewer.cpp
+++ b/kernel-shark/src/KsTraceViewer.cpp
@@ -621,9 +621,9 @@  size_t KsTraceViewer::_searchItems()
 
 		if (column == KsViewModel::TRACE_VIEW_COL_INFO ||
 		    column == KsViewModel::TRACE_VIEW_COL_LAT)
-			_proxyModel.search(&_searchFSM, &_matchList);
+			_searchItemsST();
 		else
-			_searchItemsMapReduce(column, searchText, _searchFSM.condition());
+			_searchItemsMT();
 	}
 
 	count = _matchList.count();
@@ -673,9 +673,7 @@  void KsTraceViewer::_setSearchIterator(int row)
 	}
 }
 
-void KsTraceViewer::_searchItemsMapReduce(int column,
-					  const QString &searchText,
-					  search_condition_func cond)
+void KsTraceViewer::_searchItemsMT()
 {
 	int nThreads = std::thread::hardware_concurrency();
 	std::vector<QPair<int, int>> ranges(nThreads);
@@ -685,7 +683,9 @@  void KsTraceViewer::_searchItemsMapReduce(int column,
 
 	auto lamSearchMap = [&] (const QPair<int, int> &range,
 				 bool notify) {
-		return _proxyModel.searchMap(column, searchText, cond,
+		return _proxyModel.searchMap(_searchFSM._columnComboBox.currentIndex(),
+					     _searchFSM._searchLineEdit.text(),
+					     _searchFSM.condition(),
 					     range.first, range.second,
 					     notify);
 	};
diff --git a/kernel-shark/src/KsTraceViewer.hpp b/kernel-shark/src/KsTraceViewer.hpp
index cf529ba..6080d0d 100644
--- a/kernel-shark/src/KsTraceViewer.hpp
+++ b/kernel-shark/src/KsTraceViewer.hpp
@@ -132,8 +132,9 @@  private:
 
 	size_t _searchItems();
 
-	void _searchItemsMapReduce(int column, const QString &searchText,
-				   search_condition_func cond);
+	void _searchItemsST() {_proxyModel.search(&_searchFSM, &_matchList);}
+
+	void _searchItemsMT();
 
 	void _searchEditText(const QString &);