Changeset 76111 in webkit
- Timestamp:
- Jan 19, 2011 4:23:42 AM (13 years ago)
- Location:
- trunk/LayoutTests/inspector
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/inspector/cpu-profiler-profiling-expected.txt
r76110 r76111 1 1 Tests that CPU profiling works. 2 2 3 found fib3 found pageFunction 4 4 -
trunk/LayoutTests/inspector/cpu-profiler-profiling.html
r76110 r76111 4 4 <script> 5 5 6 function fib(n) { 7 return n < 2 ? 1 : fib(n - 1) + fib(n - 2); 8 } 9 10 function eternal_fib() { 6 function pageFunction() { 11 7 console.profile(); // Make sure we capture the current callstack. 12 for (var i = 0; i < 50; ++i) {13 fib(20);14 }15 8 console.profileEnd(); 16 }17 18 function run()19 {20 eternal_fib();21 runTest();22 9 } 23 10 24 11 function initialize_ProfilerTests() 25 12 { 26 InspectorTest.findDisplayedNode = function() { 27 var panel = WebInspector.panels.profiles; 28 var tree = panel.visibleView.profileDataGridTree; 29 if (!tree) { 30 window.setTimeout(InspectorTest.findDisplayedNode, 100); 31 return; 32 } 13 InspectorTest.findPageFunctionProfileNode = function() { 14 var panel = WebInspector.panels.profiles; 15 if (!panel) 16 InspectorTest.addResult("no panel"); 17 var view = panel.visibleView; 18 if (!view) 19 InspectorTest.addResult("no view"); 20 var tree = view.profileDataGridTree; 21 if (!tree) 22 InspectorTest.addResult("no tree"); 33 23 var node = tree.children[0]; 34 if (!node) { 35 // Profile hadn't been queried yet, re-schedule. 36 window.setTimeout(InspectorTest.findDisplayedNode, 100); 37 return; 38 } 39 40 // Iterate over displayed functions and search for a function 41 // that is called "fib" or "eternal_fib". If found, this will mean 42 // that we actually have profiled page's code. 24 if (!node) 25 InspectorTest.addResult("no node"); 43 26 while (node) { 44 if (node.functionName.indexOf(" fib") !== -1) {45 InspectorTest.addResult("found fib");27 if (node.functionName.indexOf("pageFunction") !== -1) { 28 InspectorTest.addResult("found pageFunction"); 46 29 break; 47 30 } 48 31 node = node.traverseNextNode(true, null, true); 49 32 } 50 51 33 InspectorTest.completeTest(); 52 34 } 53 35 54 InspectorTest.findVisibleView = function() { 55 var panel = WebInspector.panels.profiles; 56 if (!panel.visibleView) { 57 setTimeout(InspectorTest.findVisibleView, 0); 58 return; 59 } 60 setTimeout(InspectorTest.findDisplayedNode, 0); 36 var oldRefresh = WebInspector.CPUProfileView.prototype.refresh; 37 WebInspector.CPUProfileView.prototype.refresh = function() 38 { 39 oldRefresh.call(this); 40 InspectorTest.findPageFunctionProfileNode(); 61 41 } 62 42 } … … 65 45 { 66 46 WebInspector.showPanel("profiles"); 67 InspectorTest.findVisibleView(); 47 WebInspector.panels.profiles._enableProfiling(); 48 InspectorBackend.startProfiling(); 49 InspectorTest.evaluateInConsole("pageFunction()", function done() 50 { 51 InspectorBackend.stopProfiling(); 52 }); 68 53 } 69 54 70 55 </script> 71 56 </head> 72 <body onload="run ()">57 <body onload="runTest()"> 73 58 <p> 74 59 Tests that CPU profiling works.
Note: See TracChangeset
for help on using the changeset viewer.