Orkut Gmail Agenda Docs Web mais »
Grupos visitados recentemente | Ajuda | Acessar
Página inicial dos Grupos do Google
MochiKit.DOM.getElementsByTagA ndClassName performance
Há um número excessivo de tópicos que aparecem em primeiro plano neste grupo. Para fazer com que este tópico apareça primeiro, elimine essa opção de um outro tópico.
Erro ao processar a solicitação. Tente novamente.
sinalizar
  6 mensagens - Recolher todas  -  Traduzir tudo para Traduzido (ver todos os originais)
O grupo no qual você está postando é um grupo da Usenet. As mensagens postadas neste grupo farão com que o seu e-mail fique visível para qualquer pessoa na internet.
Sua resposta não foi enviada.
Postagem publicada
 
De:
Para:
Cc:
Encaminhar para
Adicionar Cc | Adicionar Encaminhar para | Editar Assunto
Assunto:
Validação:
Com o objetivo de verificação, digite os caracteres que você vê na figura abaixo ou os números que ouvir ao clicar no ícone de acessibilidade. Ouça e digite os números que ouvir
 
takashi mizohata  
Ver perfil   Traduzir para Traduzido (ver original)
 Mais opções 3 nov, 20:23
De: takashi mizohata <bea...@gmail.com>
Data: Tue, 3 Nov 2009 17:23:09 -0500
Local: Ter 3 nov 2009 20:23
Assunto: MochiKit.DOM.getElementsByTagAndClassNam e performance

Hi All,

Forgive me, if this is a recurring argument.

Today I was looking at Firebug profiler and I realize that
getElementsByTagAndClassName takes certain percentages of processing
time.  And I took a look at the code, and I did a little bit of hand
optimization.  It doesn't change any semantics of code, but just
organizing code.  It does pass the tests of course.  And i got around
6% better performance.

Well the down side of this tweak may be the decrease of readability.
Since you need to carefully type comma between local variables.  I
usually check it with jslint before commit in order to find those
potential mistakes.  And obviously I don't much about coding
convention of MochiKit and I might need to edit the style of it.

Here I attached .patch file for this issue.  Please try it and let me
know what you think. if somebody's interested in, I can contribute
some more performance tweaks in MochiKit.

Thanks,

--
Takashi M

  getElementsByTagAndClassName.patch
2K Download

    Responder    Responder ao autor    Encaminhar  
É necessário Acessar antes de postar mensagens.
Para postar uma mensagem você precisa primeiro participar deste grupo.
Atualize seu apelido na página de configurações da inscrição antes de postar.
Você não tem a permissão necessária para postar.
Per Cederberg  
Ver perfil   Traduzir para Traduzido (ver original)
 Mais opções 4 nov, 05:14
De: Per Cederberg <cederb...@gmail.com>
Data: Wed, 4 Nov 2009 08:14:04 +0100
Local: Qua 4 nov 2009 05:14
Assunto: Re: [mochikit] MochiKit.DOM.getElementsByTagAndClassNam e performance
Generally, I think some of these optimizations make sense. Like using
"===" instead of "==" in code like this:

   typeof(x) === "string"

But I think the optimizations where variables are moved outside code
blocks and where array lengths are stored to variables should be used
with extreme caution. These are the type of things that people used to
recommend for Java code, but nowadays the virtual machines optimize
these things better by themselves. And what used to be a speedup
actually often leads to decreased performance.

For JavaScript, the VM:s are much more immature. But they are rapidly
becoming faster and more advanced. So low-level code optimizations
that result in a speedup today, might not do so just a year or two
down the road.

I think our focus here should be on clarity of intention. If some
critical-path function is extremely slow, we might want to have a look
at optimizing that specific function. But in general I think we should
refrain from low-level code optimizations that doesn't also improve
code readabilty and reduce the frequency of bugs.

Also, if speed is a problem, most serious speedups come from changes
to the algorithms and data structures involved. In this case for
instance, it might be faster to first find elements by class and then
filter out the ones with the correct tag. Or by using an
indexOf("class") on the className field before splitting it up. These
kind of optimizations will probably result in higher gains with less
reduction to the code readability.

Just my 2 cents.

Cheers,

/Per


    Responder    Responder ao autor    Encaminhar  
É necessário Acessar antes de postar mensagens.
Para postar uma mensagem você precisa primeiro participar deste grupo.
Atualize seu apelido na página de configurações da inscrição antes de postar.
Você não tem a permissão necessária para postar.
Bob Ippolito  
Ver perfil   Traduzir para Traduzido (ver original)
 Mais opções 4 nov, 14:22
De: Bob Ippolito <b...@redivi.com>
Data: Wed, 4 Nov 2009 08:22:12 -0800
Local: Qua 4 nov 2009 14:22
Assunto: Re: [mochikit] Re: MochiKit.DOM.getElementsByTagAndClassNam e performance
At least with recent browsers there are better ways to speed this up,
e.g. by leveraging more native code (getElementsByClassName and/or
XPath). None of them did this when the code was written in 2005 but I
think all of them do now (except maybe IE).


    Responder    Responder ao autor    Encaminhar  
É necessário Acessar antes de postar mensagens.
Para postar uma mensagem você precisa primeiro participar deste grupo.
Atualize seu apelido na página de configurações da inscrição antes de postar.
Você não tem a permissão necessária para postar.
Amit Mendapara  
Ver perfil   Traduzir para Traduzido (ver original)
 Mais opções 5 nov, 04:45
De: Amit Mendapara <mendapara.a...@gmail.com>
Data: Wed, 4 Nov 2009 22:45:39 -0800 (PST)
Local: Qui 5 nov 2009 04:45
Assunto: Re: MochiKit.DOM.getElementsByTagAndClassNam e performance
Look at my mochikit-ext project at https://launchpad.net/mochikit-ext.
I have implemented a jQuery style API in MochiKit.Query module (http://
bazaar.launchpad.net/~amit-mendapara/mochikit-ext/trunk/files) which
is based on Sizzle.js (http://github.com/jeresig/sizzle).

    MochiKit.DOM.getElementsByTagAndClassName("div", "some-class")

can be replaced with

    MochiKit.Query("div.some-class").get()

The Sizzle.js is the fastest selector engine out there. See
http://www.hvergi.net/arnar/public/sizzle/speed/# for the speed tests.

Regards
--
Amit Mendapara

On Nov 4, 9:22 pm, Bob Ippolito <b...@redivi.com> wrote:


    Responder    Responder ao autor    Encaminhar  
É necessário Acessar antes de postar mensagens.
Para postar uma mensagem você precisa primeiro participar deste grupo.
Atualize seu apelido na página de configurações da inscrição antes de postar.
Você não tem a permissão necessária para postar.
Fredrik  
Ver perfil   Traduzir para Traduzido (ver original)
 Mais opções 5 nov, 07:32
De: Fredrik <fblomqv...@gmail.com>
Data: Thu, 5 Nov 2009 01:32:21 -0800 (PST)
Local: Qui 5 nov 2009 07:32
Assunto: Re: MochiKit.DOM.getElementsByTagAndClassNam e performance
I created a getElementsByClassName based on this code:
http://robertnyman.com/2008/05/27/the-ultimate-getelementsbyclassname...
http://code.google.com/p/getelementsbyclassname/

Pending a full selector integration something like this should be an
easy drop-in
solution to optimize getElementsByTagAndClassName.
(IE really needs some speedup here..)

// Fredrik Blomqvist

On Nov 5, 7:45 am, Amit Mendapara <mendapara.a...@gmail.com> wrote:


    Responder    Responder ao autor    Encaminhar  
É necessário Acessar antes de postar mensagens.
Para postar uma mensagem você precisa primeiro participar deste grupo.
Atualize seu apelido na página de configurações da inscrição antes de postar.
Você não tem a permissão necessária para postar.
Alex Russell  
Ver perfil   Traduzir para Traduzido (ver original)
 Mais opções 5 nov, 19:42
De: Alex Russell <a...@dojotoolkit.org>
Data: Thu, 5 Nov 2009 13:42:41 -0800
Local: Qui 5 nov 2009 19:42
Assunto: Re: [mochikit] Re: MochiKit.DOM.getElementsByTagAndClassNam e performance

On Nov 5, 2009, at 1:32 AM, Fredrik wrote:

Actually, it's not. The Acme engine in Dojo beats it by a fair bit on  
most real-world selectors. It's stand-alone and can be easily imported  
(like Sizzle).

Regards


    Responder    Responder ao autor    Encaminhar  
É necessário Acessar antes de postar mensagens.
Para postar uma mensagem você precisa primeiro participar deste grupo.
Atualize seu apelido na página de configurações da inscrição antes de postar.
Você não tem a permissão necessária para postar.
Fim das mensagens
« Voltar às Discussões « Tópico recente     Tópico antigo »

Criar um grupo - Grupos do Google - Página inicial do Google - Termos de Uso - Política de Privacidade
©2009 Google