[OpenLayers-Dev] Re: [OpenLayers 3] type instantiation performance

Andreas Hocevar ahocevar at opengeo.org
Fri Oct 22 03:28:38 EDT 2010


On Oct 22, 2010, at 07:27 , Eric Lemoine wrote:

> On Thursday, October 21, 2010,  <christopher.schmidt at nokia.com> wrote:
>> 
>> On Oct 21, 2010, at 4:45 PM, ext Xavier Mamano (jorix) wrote:
>> Good appreciation Andreas, now Chome is still the best but it's not a
>>> 
>>> miracle :-)
>> 
>> 
>> Er, not to be too critical here or anything, but it does look like
>> Safari beats Chrome in every case except the one we're trying to
>> discuss throwing away :)
> 
> Jorix's number also show that "Object Litteral" doesn't lead to
> significantly better performance than "Pure JavaScript", which makes
> me think making this change in the lib is really worth it.

The advantage of object literals is that it's straight forward. We do have OpenLayers.Class, which gives us many advantages (like instanceof checking). So instead of introducing a new hybrid with an inherit function (remember: we got rid of one 3 years ago), I'd say two things are in order:

* Revisit OpenLayers.Class. Obviously there is room for improvement in there.
* Allow the use of object literals wherever possible.

The latter really isn't that much effort. For example, wherever we want to show the user a string representation of a pixel, we currently would do:

alert(pixel.toString());

If we accept an instance of OpenLayers.Pixel or an object literal, we can safely do

alert(OpenLayers.Pixel.prototype.toString.call(pixel);

No need to distinguish between an OpenLayers.Pixel instance and an object literal.

And speaking of room for other performance improvements: we often create clones internally where we would not need to. This is also very expensive.

Regards,
Andreas.

> 
> -- 
> Eric Lemoine
> 
> Camptocamp France SAS
> Savoie Technolac, BP 352
> 73377 Le Bourget du Lac, Cedex
> 
> Tel : 00 33 4 79 44 44 96
> Mail : eric.lemoine at camptocamp.com
> http://www.camptocamp.com
> _______________________________________________
> Dev mailing list
> Dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-dev



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.



More information about the Dev mailing list