Web Inspector: CPU Profile: Search in "heavy" mode is very slow.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Dec 2012 08:54:51 +0000 (08:54 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Dec 2012 08:54:51 +0000 (08:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=103682

Patch by Eugene Klyuchnikov <eustas@chromium.org> on 2012-12-14
Reviewed by Pavel Feldman.

In "heavy" mode the searchable tree is much larger than original tree.
That is why search can cause watchdog timer fired.

Simple optimization makes search much faster.

* inspector/front-end/CPUProfileView.js:
(WebInspector.CPUProfileView.prototype.searchCanceled):
Fix cleanup.
(WebInspector.CPUProfileView.prototype.matchesQuery):
Precompute regexp.
(WebInspector.CPUProfileView.prototype.performSearch):
Use precomputed regexp instead of generating one on each iteration.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@137729 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/CPUProfileView.js

index 500a307..b6d4e49 100644 (file)
@@ -1,3 +1,23 @@
+2012-12-14  Eugene Klyuchnikov  <eustas@chromium.org>
+
+        Web Inspector: CPU Profile: Search in "heavy" mode is very slow.
+        https://bugs.webkit.org/show_bug.cgi?id=103682
+
+        Reviewed by Pavel Feldman.
+
+        In "heavy" mode the searchable tree is much larger than original tree.
+        That is why search can cause watchdog timer fired.
+
+        Simple optimization makes search much faster.
+
+        * inspector/front-end/CPUProfileView.js:
+        (WebInspector.CPUProfileView.prototype.searchCanceled):
+        Fix cleanup.
+        (WebInspector.CPUProfileView.prototype.matchesQuery):
+        Precompute regexp.
+        (WebInspector.CPUProfileView.prototype.performSearch):
+        Use precomputed regexp instead of generating one on each iteration.
+
 2012-12-13  Yury Semikhatsky  <yurys@chromium.org>
 
         Web Inspector: collect native heap graph and report it to the front-end
index 9e3d5af..fb42dc2 100644 (file)
@@ -186,6 +186,7 @@ WebInspector.CPUProfileView.prototype = {
 
                 delete profileNode._searchMatchedSelfColumn;
                 delete profileNode._searchMatchedTotalColumn;
+                delete profileNode._searchMatchedAverageColumn;
                 delete profileNode._searchMatchedCallsColumn;
                 delete profileNode._searchMatchedFunctionColumn;
 
@@ -231,6 +232,8 @@ WebInspector.CPUProfileView.prototype = {
         if (!isNaN(queryNumber) && !(greaterThan || lessThan))
             equalTo = true;
 
+        var matcher = new RegExp(query.escapeForRegExp(), "i");
+
         function matchesQuery(/*ProfileDataGridNode*/ profileDataGridNode)
         {
             delete profileDataGridNode._searchMatchedSelfColumn;
@@ -298,7 +301,7 @@ WebInspector.CPUProfileView.prototype = {
                     profileDataGridNode._searchMatchedCallsColumn = true;
             }
 
-            if (profileDataGridNode.functionName.hasSubstring(query, true) || profileDataGridNode.url.hasSubstring(query, true))
+            if (profileDataGridNode.functionName.match(matcher) || profileDataGridNode.url.match(matcher))
                 profileDataGridNode._searchMatchedFunctionColumn = true;
 
             if (profileDataGridNode._searchMatchedSelfColumn ||