[OpenLayers-Trac] [OpenLayers] #2874: toFloat hell

OpenLayers trac-20090302 at openlayers.org
Tue Oct 12 16:44:25 EDT 2010


#2874: toFloat hell
-----------------------+----------------------------------------------------
 Reporter:  erilem     |       Owner:             
     Type:  bug        |      Status:  new        
 Priority:  major      |   Milestone:  3.0 Release
Component:  BaseTypes  |     Version:  2.10       
 Keywords:             |       State:             
-----------------------+----------------------------------------------------
 As now known {{{toFloat}}} represents a pretty high percentage of
 execution time when panning the map.

 {{{toFloat}}} is used in two classes only: {{{LonLat}}} and {{{Bounds}}}.
 In {{{LonLat}}} it's used in the constructor, and in {{{add}}}. In
 {{{Bounds}}} it's used in the constructor, and in {{{contains}}}.

 FireBug's profile tool reports that {{{toFloat}}} represents ~10% of
 execution time when panning the map.

 I did some experiments, removing {{{toFloat}}} calls and doing profiles.
 The results:

  * when removing {{{toFloat}}} from {{{LonLat:init}}} then {{{toFloat}}}
 == ~7%
  * when also removing {{{toFloat}}} from {{{LonLat:add}}} then
 {{{toFloat}}} == ~7% (no effect)
  * when also removing {{{toFloat}}} from the {{{Bounds:init}}} then
 {{{toFloat}}} == ~2%
  * and when also removing {{{toFloat}}} {{{Bounds:contains}}} method then
 {{{toFloat}}} == 0%

 This suggests that we'd better not call {{{toFloat}}} from {{{LonLat}}}
 and {{{Bounds}}}, and make {{{LonLat}}} and {{{Bounds}}} users responsible
 for providing floats.

-- 
Ticket URL: <http://trac.openlayers.org/ticket/2874>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer


More information about the Trac mailing list