OpenLayers OpenLayers

Ticket #1459 (closed bug: fixed)

Opened 2 years ago

Last modified 2 years ago

getMousePosition performance

Reported by: openlayers Assigned to: crschmidt
Priority: critical Milestone: 2.7 Release
Component: Events Version: SVN
Keywords: Cc:
State: Complete

Description

improved version of getMousePosition.

Attachments

ol.events.patch (0.5 kB) - added by openlayers on 03/24/08 10:54:50.
remove cache hash from patch
getmouseposition.diff (2.5 kB) - added by tcoulter on 07/30/08 00:15:13.
includexy.patch (7.4 kB) - added by crschmidt on 07/30/08 17:02:52.
includexy.2.patch (7.4 kB) - added by crschmidt on 07/30/08 17:03:39.

Change History

03/24/08 10:28:04 changed by openlayers

Before patch getMousePosition takes 45% (by simple panning of map)

getMousePosition	470	45.14%	1024.654ms	1059.418ms	2.254ms	0.158ms	19.59ms	Events.js (line 705)
renderTile	166	11.6%	263.207ms	338.136ms	2.037ms	1.505ms	4.294ms	Image.js (line 157)
Class	4562	6.58%	149.463ms	252.983ms	0.055ms	0.029ms	0.373ms	Class.js (line 23)
show	154	5.77%	130.958ms	130.958ms	0.85ms	0.352ms	9.423ms	Image.js (line 393)
initialize	1395	2.79%	63.436ms	63.436ms	0.045ms	0.013ms	0.345ms	Bounds.js (line 55)

after patch the profile top is:

renderTile	323	30.26%	497.764ms	647.118ms	2.003ms	1.545ms	19.221ms	Image.js (line 157)
show	309	13.82%	227.33ms	227.33ms	0.736ms	0.344ms	9.167ms	Image.js (line 393)
Class	4117	7.55%	124.206ms	209.452ms	0.051ms	0.029ms	0.304ms	Class.js (line 23)
modifyDOMElement	646	4.88%	80.236ms	80.236ms	0.124ms	0.058ms	1.348ms	Util.js (line 153)
initialize	1333	3.24%	53.327ms	53.327ms	0.04ms	0.011ms	0.127ms	Bounds.js (line 55)
........
getMousePosition	448	1.94%	31.89ms	50.898ms	0.114ms	0.025ms	0.533ms

linux ubuntu 7.10 + firefox3b4 + firebug 1.1 profiler

03/24/08 10:54:50 changed by openlayers

  • attachment ol.events.patch added.

remove cache hash from patch

03/24/08 18:00:30 changed by crschmidt

  • milestone changed from 2.6 Release to 2.7 Release.

07/28/08 14:47:50 changed by euzuro

  • owner changed from euzuro to tschaub.
  • priority changed from major to critical.

07/29/08 19:49:54 changed by crschmidt

07/30/08 00:14:58 changed by tcoulter

Adding a patch for the example shown in the email linked above. Also made each element observe the scroll event to update the cached data as needed.

Someone with more knowledge of the inner workings should test to see if the scroll event actually does what it's supposed to.

07/30/08 00:15:13 changed by tcoulter

  • attachment getmouseposition.diff added.

07/30/08 10:54:19 changed by euzuro

  • owner changed from tschaub to crschmidt.
  • state changed from Needs More Work to Review.

07/30/08 17:02:52 changed by crschmidt

  • attachment includexy.patch added.

07/30/08 17:03:39 changed by crschmidt

  • attachment includexy.2.patch added.

07/30/08 17:23:19 changed by crschmidt

  • keywords deleted.
  • status changed from new to closed.
  • state changed from Review to Complete.
  • resolution set to fixed.

(In [7615]) Change getMousePosition to only be called automatically *if* the 'includeXY' flag on the Events object is set to true. This ends up meaning that we save a lot of unneccesary getMousePosition calls because (for example) the layer doesn't need to include the .xy property. In addition, we add in speed improvements via caching to the getMousePosition, courtesy the work from pgiraud (which was worked on further by tcoulter) -- this results in significantly improved getMousePosition performance improvements in 'real life' situations that are more like the cases that people use OpenLayers, with a higher number of containing divs (and also clearly demonstrate a gain in performance even in the simple case.)

The end result is:

  • In typical map movement over the map, (n / n+1) fewer calls to getMousePosition, where n is the number of active layers when dragging over the map.
  • In the simple case, 40% faster getMousePosition performance -- and in more complex cases, significantly more performance improvements.

To drop the former improvement, which may affect some applications (as described in the includeXY documentation) simply set:

OpenLayers.Events.prototype.includeXY = true;

This will restore the 'every element has an xy property always' behavior that was the case beore this patch.

r=me,tschaub, work by pgiraud related to (See #1509), and (Closes #1459)