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

Unified Diff: LayoutTests/fast/dom/HTMLDialogElement/hit-test-benchmark.html

Issue 16347002: Perf test for hit testing. Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix y update Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/dom/HTMLDialogElement/hit-test-benchmark.html
diff --git a/LayoutTests/fast/dom/HTMLDialogElement/hit-test-benchmark.html b/LayoutTests/fast/dom/HTMLDialogElement/hit-test-benchmark.html
new file mode 100644
index 0000000000000000000000000000000000000000..f8b3d7a90ef5a333a989d6e30236a0f17ff1e189
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLDialogElement/hit-test-benchmark.html
@@ -0,0 +1,78 @@
+<body>
+<style>
+ .outer {
+ position: relative;
+ margin: 0.25px;
+ padding: 0.25px;
+ }
+ .inner {
+ width: 100px;
+ height: 100px;
+ background: red;
+ }
+</style>
+<script src="../../js/resources/js-test-pre.js"></script>
+<div id="test"></div> <div id="console"></div>
+<script>
+
+var reportedPosition;
+var innerElement;
+var testElement = document.getElementById('test');
+
+function setupFunction(magnitude)
+{
+ testElement.innerHTML = '';
+ var element, parent = testElement;
+ for (var i = 0; i < magnitude; i++) {
+ element = document.createElement('div');
+ element.innerText = 'hello';
+ element.className = 'outer';
+ parent.appendChild(element);
+ parent = element;
+ }
+ element = document.createElement('div');
+ element.className = 'inner';
+ element.innerText = 'inner';
+ parent.appendChild(element);
+ element.addEventListener('mousemove', function(e) {
+ reportedPosition = e.offsetX + ', ' + e.offsetY;
+ });
+ element.addEventListener('click', function(e) {
+ debug("i'm clicked");
+ });
+ innerElement = element;
+ rect = innerElement.getBoundingClientRect();
+ window.scrollTo(rect.left - window.innerWidth / 2, rect.top - window.innerHeight / 2);
+}
+
+function test(iterations)
+{
+ rect = innerElement.getBoundingClientRect();
+ target = {};
+ target.x = rect.left + (rect.width / 2);
+ target.y = rect.top + (rect.height / 2);
+ increment = 5;
+ if (window.eventSender) {
+ for (i = 0; i < iterations; ++i) {
+ x = 0;
+ y = 0;
+ m = target.y / target.x;
+ while (Math.abs(x - target.x) > increment) {
+ x += increment;
+ y = m * x;
+ eventSender.mouseMoveTo(x, y);
+ }
+ eventSender.mouseMoveTo(target.x, target.y);
+ }
+ }
+}
+
+exponent = 8;
+setupFunction(Math.pow(2, exponent));
+start = new Date().getTime();
+test(1000);
+stop = new Date().getTime();
+debug('Time elapsed: ' + (stop - start));
+debug(reportedPosition);
+</script>
+</body>
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698