...using strict creates overhead although it's not an optimization to write home about.

I assume you're referring to the runtime check for symbolic references, as that is the only run-time component for stricture?

$ perl -MO=Deparse -e '{use strict; my $a = 1}' { use strict 'refs'; my $a = 1; }

Well, I've taken the liberty of benchmarking the use of strict refs, and I must say it's a meager optimization indeed. I ran this code on a (new) completely unloaded machine: it would seem to me that the difference is noticable, but seems to be drowned out by noise almost completely.

use Benchmark qw(:all); cmpthese( 10000000, { with => sub {use strict 'refs'; my $a = 1; my $b = 2}, without => sub {my $a = 1; my $b = 2}, } ); __END__ Rate with without with 3378378/s -- -7% without 3623188/s 7% -- Rate without with without 3802281/s -- -3% with 3937008/s 4% -- Rate with without with 3412969/s -- -15% without 4032258/s 18% -- Rate with without with 4048583/s -- -3% without 4166667/s 3% -- Rate with without with 3460208/s -- -9% without 3787879/s 9% --

It would seem to me that if you need this type of optimization, you'd better start coding parts of your program in C ;-). So I wouldn't remove "use strict" from a production script for this reason: the likelyhood of a "quick hack" in the future on that production script messing up things without warning, would be just too great for me, from a sysadmin point of view.

Liz


In reply to Re: Re: to strict or not to strict by liz
in thread to strict or not to strict by castaway

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.