Espera, você leu errado, Márcio. <br><br>Como eu falei &quot;acima&quot;,&nbsp; Rate = Velocidade. &quot;tr&quot; rodou mais de 3 milhões de vezes por segundo, enquanto &quot;array&quot; fez apenas 1 milhão. <br><br>The manual says &quot;This chart is sorted from slowest to fastest&quot;; that meanifica &quot;do mais lento pro mais rápido&quot;, não o contrário.
<br><br>[]s<br>Wendel (mixing línguas for fun)<br><br><div class="gmail_quote">On Nov 21, 2007 3:43 PM, Márcio Vitor &lt;<a href="mailto:cromo.jml@gmail.com">cromo.jml@gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
O gráfico é uma comparação de velocidade entre os emparelhamentos<br>indicados pelo Solli:<br><div class="Ih2E3d"><br>&gt; &gt;cmpthese(-1, {<br>&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;array&#39; =&gt; &#39;@{[$var =~ /a/g]}&#39;,<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;while&#39; =&gt; &#39;while ( $var =~ /a/g ) { $qtd02++}&#39;,<br>&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;tr&#39; &nbsp; &nbsp;=&gt; &#39;$var =~ y/a/A/&#39;<br>&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br><br></div>É classificado do mais rápido ao mais lento, a primeira coluna Rate
<br>mostra a velocidade com que cada um foi executado, o restante mostra o<br>percentual de perfomance entre cada um, repare que a array é comparado<br>com while e tr e como ela é a mais rápida, todos mostram um percentual
<br>negativo sobre ela, assim como o array teve uma perfomance 247% melhor<br>que o tr.<br>Ah, tá na manual:<br><br>cmpthese ( RESULTSHASHREF, [ STYLE ] )<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Optionally calls timethese(), then outputs comparison
<br>chart. &nbsp;This:<br><br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmpthese( -1, { a =&gt; &quot;++\$i&quot;, b =&gt; &quot;\$i *= 2&quot; } ) ;<br><br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outputs a chart like:<br><br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Rate &nbsp; &nbsp;b &nbsp; &nbsp;a<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b 2831802/s &nbsp; -- -61%<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a 7208959/s 155% &nbsp; --<br><br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; This chart is sorted from slowest to fastest, and<br>shows the percent speed difference between each pair<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; of tests.<br><br><br>Abraços<br><font color="#888888"><br>Márcio Vitor<br></font><div><div></div><div class="Wj3C7c"><br><br>On Nov 21, 2007 3:27 PM, &nbsp;&lt;<a href="mailto:fernandolouis@terra.com.br">fernandolouis@terra.com.br
</a>&gt; wrote:<br>&gt; &lt;resultado&gt;<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Rate array while &nbsp; &nbsp;tr<br>&gt; array 1090778/s &nbsp; &nbsp;-- &nbsp;-54% &nbsp;-71%<br>&gt; while 2388776/s &nbsp;119% &nbsp; &nbsp;-- &nbsp;-37%<br>&gt; tr &nbsp; &nbsp;3781862/s &nbsp;247% &nbsp; 58% &nbsp; &nbsp;--<br>&gt; &lt;/resultado&gt;
<br>&gt;<br>&gt;<br>&gt;<br>&gt; ----- Original Message -----<br>&gt; From: Márcio Vitor<br>&gt; To: Cascavel Perl Mongers<br>&gt;<br>&gt;<br>&gt; Sent: Wednesday, November 21, 2007 2:47 PM<br>&gt; Subject: Re: [Cascavel-pm] Contando caractares
<br>&gt;<br>&gt; Poxa Fernando na boa, fazer uma pesquisa não é tão mais difícil do que<br>&gt; perguntar na lista, fiz a pesquisa e a primeira ocorrência é deste link (em<br>&gt; português):<br>&gt; <a href="http://pt.wikipedia.org/wiki/Benchmark" target="_blank">
http://pt.wikipedia.org/wiki/Benchmark</a><br>&gt;<br>&gt; Abraços<br>&gt;<br>&gt; Márcio Vitor<br>&gt;<br>&gt;<br>&gt; On Nov 21, 2007 2:41 PM, &lt;<a href="mailto:fernandolouis@terra.com.br">fernandolouis@terra.com.br</a>
&gt; wrote:<br>&gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; Amigo,<br>&gt; &gt;<br>&gt; &gt; não compreendi o &lt;resultado&gt;&lt;/resultado&gt;<br>&gt; &gt;<br>&gt; &gt; o que exatamente siginifcam os valores? E pra que serve o &quot;Benchmark&quot;?
<br>&gt; &gt;<br>&gt; &gt; []s,<br>&gt; &gt; Fernando<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; ----- Original Message -----<br>&gt; &gt; From: Solli Honorio<br>&gt; &gt; To: Cascavel Perl Mongers<br>&gt; &gt; Sent: Tuesday, November 20, 2007 6:28 PM
<br>&gt; &gt; Subject: Re: [Cascavel-pm] Contando caractares<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; Não resisti, que tal um golfe ?<br>&gt; &gt;<br>&gt; &gt; $q=$v=~y/a//;<br>&gt; &gt;<br>&gt; &gt; ... e tem outra coisa, o &#39;tr&#39; ou &#39;y&#39; é mais rápido ...
<br>&gt; &gt; &lt;code&gt;<br>&gt; &gt; use Benchmark qw(:all) ;<br>&gt; &gt; my $var &nbsp; = &#39;parlamentarismo&#39;;<br>&gt; &gt;<br>&gt; &gt; cmpthese(-1, {<br>&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;array&#39; =&gt; &#39;@{[$var =~ /a/g]}&#39;,
<br>&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;while&#39; =&gt; &#39;while ( $var =~ /a/g ) { $qtd02++}&#39;,<br>&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;tr&#39; &nbsp; &nbsp;=&gt; &#39;$var =~ y/a/A/&#39;<br>&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<br>&gt; &gt; &lt;/code&gt;
<br>&gt; &gt;<br>&gt; &gt; &lt;resultado&gt;<br>&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Rate array while &nbsp; &nbsp;tr<br>&gt; &gt; array 1090778/s &nbsp; &nbsp;-- &nbsp;-54% &nbsp;-71%<br>&gt; &gt; while 2388776/s &nbsp;119% &nbsp; &nbsp;-- &nbsp;-37%<br>&gt; &gt; tr &nbsp; &nbsp;3781862/s &nbsp;247% &nbsp; 58% &nbsp; &nbsp;--
<br>&gt; &gt; &lt;/resultado&gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; On Nov 20, 2007 3:15 PM, Adriano Ferreira &lt;<a href="mailto:a.r.ferreira@gmail.com">a.r.ferreira@gmail.com</a>&gt; wrote:<br>&gt; &gt;<br>&gt; &gt; &gt;
<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; On Nov 20, 2007 9:35 AM, &nbsp;&lt;<a href="mailto:fernandolouis@terra.com.br">fernandolouis@terra.com.br</a>&gt; wrote:<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; Dae Pessoal... olha só...
<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; $variavel = &quot;casa&quot;;<br>&gt; &gt; &gt; &gt; Como faço pra contar quantos &quot;a&quot; tem em $variavel?<br>&gt; &gt; &gt; &gt; Tentei o seguinte, mas não fucionou:<br>
&gt; &gt; &gt; &gt; $qtd = $variavel =~ m /a/g;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; Se o que você quer é apenas contar caracteres, use tr//<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; $qtd = $variavel =~ tr/a/a/;<br>&gt; &gt; &gt;
<br>&gt; &gt; &gt; Leia sobre o operator em &quot;perldoc perlop&quot; e sobre este uso em<br>&gt; particular.<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; []s,<br>&gt; &gt; &gt; &gt; Fernando<br>&gt; &gt; &gt;
<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; _______________________________________________<br>&gt; &gt; &gt; &gt; Cascavel-pm mailing list<br>&gt; &gt; &gt; &gt; <a href="mailto:Cascavel-pm@pm.org">Cascavel-pm@pm.org
</a><br>&gt; &gt; &gt; &gt; <a href="http://mail.pm.org/mailman/listinfo/cascavel-pm" target="_blank">http://mail.pm.org/mailman/listinfo/cascavel-pm</a><br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; _______________________________________________
<br>&gt; &gt; &gt; Cascavel-pm mailing list<br>&gt; &gt; &gt; <a href="mailto:Cascavel-pm@pm.org">Cascavel-pm@pm.org</a><br>&gt; &gt; &gt; <a href="http://mail.pm.org/mailman/listinfo/cascavel-pm" target="_blank">http://mail.pm.org/mailman/listinfo/cascavel-pm
</a><br>&gt; &gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; --<br>&gt; &gt; &quot;o animal satisfeito dorme&quot;. - Guimarães Rosa<br>&gt; &gt;<br>&gt; &gt; ________________________________<br>&gt;<br>&gt; &gt;
<br>&gt; &gt; _______________________________________________<br>&gt; &gt;<br>&gt; &gt; Cascavel-pm mailing list<br>&gt; &gt; <a href="mailto:Cascavel-pm@pm.org">Cascavel-pm@pm.org</a><br>&gt; &gt; <a href="http://mail.pm.org/mailman/listinfo/cascavel-pm" target="_blank">
http://mail.pm.org/mailman/listinfo/cascavel-pm</a><br>&gt; &gt; _______________________________________________<br>&gt; &gt; Cascavel-pm mailing list<br>&gt; &gt; <a href="mailto:Cascavel-pm@pm.org">Cascavel-pm@pm.org</a>
<br>&gt; &gt; <a href="http://mail.pm.org/mailman/listinfo/cascavel-pm" target="_blank">http://mail.pm.org/mailman/listinfo/cascavel-pm</a><br>&gt; &gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; &nbsp;________________________________<br>
&gt;<br>&gt;<br>&gt; _______________________________________________<br>&gt;<br>&gt; Cascavel-pm mailing list<br>&gt; <a href="mailto:Cascavel-pm@pm.org">Cascavel-pm@pm.org</a><br>&gt; <a href="http://mail.pm.org/mailman/listinfo/cascavel-pm" target="_blank">
http://mail.pm.org/mailman/listinfo/cascavel-pm</a><br></div></div>&gt; _______________________________________________<br><div><div></div><div class="Wj3C7c">&gt; Cascavel-pm mailing list<br>&gt; <a href="mailto:Cascavel-pm@pm.org">
Cascavel-pm@pm.org</a><br>&gt; <a href="http://mail.pm.org/mailman/listinfo/cascavel-pm" target="_blank">http://mail.pm.org/mailman/listinfo/cascavel-pm</a><br>&gt;<br>_______________________________________________<br>Cascavel-pm mailing list
<br><a href="mailto:Cascavel-pm@pm.org">Cascavel-pm@pm.org</a><br><a href="http://mail.pm.org/mailman/listinfo/cascavel-pm" target="_blank">http://mail.pm.org/mailman/listinfo/cascavel-pm</a><br></div></div></blockquote></div>
<br><br clear="all"><br>-- <br>[]s<br>Wendel