[Moscow.pm] Perl Socket application

Eugene Kaltashkin zhecka на gmail.com
Сб Ноя 10 03:04:34 PST 2007


On Nov 10, 2007 1:28 PM, Andrey <jerom+moscow-pm на bibirevo.net> wrote:
> Eugene Kaltashkin пишет:
> > Второй вопрос на который не могу нигде найти ответа.
> > какая структурная форма для констант лучше ?
> >
> > sub DEBUG() { 0 }
> > или
> > use constant DEBUG => 0;
> > или все таки
> > $DEBUG = 0;
> >
> > странно, но на $DEBUG обработка данных быстрее, хотя должно быть
> > наоборот при использовании constant.
> >
>
> Конвей, страница 55  :-)  (c) Shitov: Лучше всего делать так:
>
> use Readonly;
> Readonly my $DEBUG => 0;

Что-то я не уверен в этой затее. В чем сила брат ? ;)

       Readonly.pm does impose a performance penalty.  It's pretty slow.  How
       slow?  Run the "benchmark.pl" script that comes with Readonly.  On my
       test system, "use constant", typeglob constants, and regular read/write
       Perl variables were all about the same speed, and Readonly.pm constants
       were about 1/20 the speed.

       However, there is relief.  There is a companion module available, Read-
       only::XS.  If it is installed on your system, Readonly.pm uses it to
       make read-only scalars much faster.  With Readonly::XS, Readonly
       scalars are as fast as the other types of variables.  Readonly arrays
       and hashes will still be relatively slow.  But it's likely that most of
       your Readonly variables will be scalars.

ЗЫ: как посидели вчера ?

-- 
Best Regards
ZHECKA-RIPN


Подробная информация о списке рассылки Moscow-pm