extra constructor calls, inefficent loop variable scope?

Discussion in 'Perl' started by ixtahdoom, Jul 9, 2004.

  1. ixtahdoom

    ixtahdoom Guest

    Hi All,

    Does the declaration of a variable impact performance? For exmaple:

    Loop A:

    while (<>) {
    my $something = $_;
    }

    Loop B:

    my $something;
    while (<>) {
    $something = $_;
    }

    Is either one better w.r.t. performance?

    Thanks,
    itd
     
    ixtahdoom, Jul 9, 2004
    #1
    1. Advertising

  2. ixtahdoom wrote:
    > Does the declaration of a variable impact performance? For exmaple:
    >
    > Loop A:
    >
    > while (<>) {
    > my $something = $_;
    > }
    >
    > Loop B:
    >
    > my $something;
    > while (<>) {
    > $something = $_;
    > }
    >
    > Is either one better w.r.t. performance?


    I have no idea. If you want to know, make use of the Benchmark module.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Jul 9, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Honne Gowda A
    Replies:
    2
    Views:
    882
    Karl Heinz Buchegger
    Oct 31, 2003
  2. metaperl.com
    Replies:
    7
    Views:
    268
    metaperl.com
    Sep 18, 2008
  3. mathieu
    Replies:
    3
    Views:
    600
    Bo Persson
    Sep 4, 2009
  4. David Filmer
    Replies:
    19
    Views:
    248
    Kevin Collins
    May 21, 2004
  5. Isaac Won
    Replies:
    9
    Views:
    387
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page