Title: [137266] trunk/LayoutTests
- Revision
- 137266
- Author
- [email protected]
- Date
- 2012-12-11 01:15:43 -0800 (Tue, 11 Dec 2012)
Log Message
Web Inspector: better coverage for inspector/profiler/cpu-profiler-profiling-without-inspector.html
https://bugs.webkit.org/show_bug.cgi?id=104071
Reviewed by Pavel Feldman.
Extended test by spinning several function for a total of 400ms to provide coverage for sampling profiler.
* inspector/profiler/cpu-profiler-profiling-without-inspector-expected.txt:
* inspector/profiler/cpu-profiler-profiling-without-inspector.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (137265 => 137266)
--- trunk/LayoutTests/ChangeLog 2012-12-11 09:11:24 UTC (rev 137265)
+++ trunk/LayoutTests/ChangeLog 2012-12-11 09:15:43 UTC (rev 137266)
@@ -1,3 +1,15 @@
+2012-12-11 Andrey Kosyakov <[email protected]>
+
+ Web Inspector: better coverage for inspector/profiler/cpu-profiler-profiling-without-inspector.html
+ https://bugs.webkit.org/show_bug.cgi?id=104071
+
+ Reviewed by Pavel Feldman.
+
+ Extended test by spinning several function for a total of 400ms to provide coverage for sampling profiler.
+
+ * inspector/profiler/cpu-profiler-profiling-without-inspector-expected.txt:
+ * inspector/profiler/cpu-profiler-profiling-without-inspector.html:
+
2012-12-10 Mihnea Ovidenie <[email protected]>
[CSSRegions] Clean-up style for 2 regions expected results files
Modified: trunk/LayoutTests/inspector/profiler/cpu-profiler-profiling-without-inspector-expected.txt (137265 => 137266)
--- trunk/LayoutTests/inspector/profiler/cpu-profiler-profiling-without-inspector-expected.txt 2012-12-11 09:11:24 UTC (rev 137265)
+++ trunk/LayoutTests/inspector/profiler/cpu-profiler-profiling-without-inspector-expected.txt 2012-12-11 09:15:43 UTC (rev 137266)
@@ -1,6 +1,9 @@
Tests that CPU profiling works.
Doesn't open Inspector, uses console.profile....
+ doWork (line 40): ~400ms
+ functionA (line 27): ~400ms
+ sleep (line 18): ~200ms
+ functionB (line 23): ~200ms
+ sleep (line 18): ~200ms
-Found pageFunction
-
Modified: trunk/LayoutTests/inspector/profiler/cpu-profiler-profiling-without-inspector.html (137265 => 137266)
--- trunk/LayoutTests/inspector/profiler/cpu-profiler-profiling-without-inspector.html 2012-12-11 09:11:24 UTC (rev 137265)
+++ trunk/LayoutTests/inspector/profiler/cpu-profiler-profiling-without-inspector.html 2012-12-11 09:15:43 UTC (rev 137266)
@@ -1,77 +1,91 @@
<html>
<head>
-<script>
+<script src="" type="application/x-_javascript_"></script>
+<script type="application/x-_javascript_">
-if (window.testRunner)
+if (window.testRunner) {
testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+}
+
if (window.internals)
internals.setJavaScriptProfilingEnabled(true);
-function pageFunction()
+// Here and below, the opening brace is on the same line as function declaration
+// intendionally, as it compensates for differences between the ways JSC and V8
+// use to report source lines for functions (V8 reports line of function(), JSC
+// the line of the brace)
+function sleep(milliseconds) {
+ var spinUntil = Date.now() + milliseconds;
+ while (Date.now() < spinUntil) {}
+}
+
+function functionB() {
+ sleep(200);
+}
+
+function functionA() {
+ sleep(200);
+ functionB();
+}
+
+function startProfiling()
{
- console.profile("outer");
- console.profile("inner"); // [Chromium] Make sure we capture the current callstack.
- console.profileEnd("outer");
- console.profileEnd("inner");
+ console.profile("outer1");
+ console.profile("inner1"); // [Chromium] Make sure we capture the current callstack.
+ // workaround for http://crbug.com/164304
+ setTimeout(doWork, 100);
}
-function startTest()
-{
- pageFunction();
+function doWork() {
+ functionA();
+ console.profileEnd("outer1");
+ console.profileEnd("inner1");
printResult();
if (window.testRunner)
- testRunner.notifyDone();
+ testRunner.notifyDone();
}
+function startTest()
+{
+ startProfiling();
+}
+
function printResult()
{
- var preElement = document.createElement("pre");
- preElement.appendChild(document.createTextNode("\n"));
-
var profiles = console.profiles;
for (var i = 0; i < profiles.length; ++i) {
var profile = ""
- if (profile.title !== "inner")
+ if (profile.title !== "inner1")
continue;
- var functionName = "pageFunction";
- if (findFunctionInProfile(profile.head, functionName))
- preElement.appendChild(document.createTextNode("Found " + functionName));
- else {
- preElement.appendChild(document.createTextNode("!!! Not found " + functionName));
- preElement.appendChild(document.createTextNode("\n\n"));
- printProfileNodeWithoutTime(preElement, profile.head, "");
- }
- preElement.appendChild(document.createTextNode("\n"));
+ dumpNode(profile.head)
}
-
- document.getElementById("output").appendChild(preElement);
}
-function printProfileNodeWithoutTime(preElement, node, space)
+var functionsWhiteList = {
+ "sleep": 1,
+ "functionA": 1,
+ "functionB": 1,
+ "doWork": 1
+};
+
+function dumpNode(node, prefix)
{
if (!node.visible)
return;
+ prefix = prefix || "";
+
+ const roundingThreshold = 100; // Time should be good within 100ms
+ var time = Math.round(node.totalTime / roundingThreshold) * roundingThreshold;
+ if (time && functionsWhiteList[node.functionName])
+ output(prefix + node.functionName + " (line " + node.lineNumber + "): ~" + time +"ms");
- var line = space + node.functionName + " (line " + node.lineNumber + ")\n";
- preElement.appendChild(document.createTextNode(line));
-
var children = node.children();
for (var i = 0; i < children.length; ++i)
- printProfileNodeWithoutTime(preElement, children[i], space + " ");
+ dumpNode(children[i], prefix + " ");
}
+</script>
-function findFunctionInProfile(node, functionName)
-{
- if (node.functionName === functionName)
- return true;
- var children = node.children();
- for (var i = 0; i < children.length; ++i)
- if (findFunctionInProfile(children[i], functionName))
- return true;
- return false;
-}
-
-</script>
</head>
<body _onload_="startTest()">
<p>
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes