Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1263)

Side by Side Diff: LayoutTests/inspector/profiler/cpu-profiler-profiling-without-inspector.html

Issue 15816002: Remove console.profiles from window.console API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <html>
2 <head>
3 <script>
4
5 if (window.testRunner)
6 testRunner.dumpAsText();
7 if (window.internals)
8 internals.setJavaScriptProfilingEnabled(true);
9
10 function pageFunction()
11 {
12 console.profile("outer");
13 console.profile("inner"); // [Chromium] Make sure we capture the current ca llstack.
14 console.profileEnd("outer");
15 console.profileEnd("inner");
16 }
17
18 function startTest()
19 {
20 pageFunction();
21 printResult();
22 if (window.testRunner)
23 testRunner.notifyDone();
24 }
25
26 function printResult()
27 {
28 var preElement = document.createElement("pre");
29 preElement.appendChild(document.createTextNode("\n"));
30
31 var profiles = console.profiles;
32 for (var i = 0; i < profiles.length; ++i) {
33 var profile = profiles[i];
34 if (profile.title !== "inner")
35 continue;
36 var functionName = "pageFunction";
37 if (findFunctionInProfile(profile.head, functionName))
38 preElement.appendChild(document.createTextNode("Found " + functionNa me));
39 else {
40 preElement.appendChild(document.createTextNode("!!! Not found " + fu nctionName));
41 preElement.appendChild(document.createTextNode("\n\n"));
42 printProfileNodeWithoutTime(preElement, profile.head, "");
43 }
44 preElement.appendChild(document.createTextNode("\n"));
45 }
46
47 document.getElementById("output").appendChild(preElement);
48 }
49
50 function printProfileNodeWithoutTime(preElement, node, space)
51 {
52 if (!node.visible)
53 return;
54
55 var line = space + node.functionName + " (line " + node.lineNumber + ")\n";
56 preElement.appendChild(document.createTextNode(line));
57
58 var children = node.children();
59 for (var i = 0; i < children.length; ++i)
60 printProfileNodeWithoutTime(preElement, children[i], space + " ");
61 }
62
63 function findFunctionInProfile(node, functionName)
64 {
65 if (node.functionName === functionName)
66 return true;
67 var children = node.children();
68 for (var i = 0; i < children.length; ++i)
69 if (findFunctionInProfile(children[i], functionName))
70 return true;
71 return false;
72 }
73
74 </script>
75 </head>
76 <body onload="startTest()">
77 <p>
78 Tests that CPU profiling works.<br>
79 Doesn't open Inspector, uses <b>console.profile...</b>.
80
81 <div id="output"></div>
82 </p>
83 </body>
84 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698