Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > extra constructor calls, inefficent loop variable scope?

Reply
Thread Tools

extra constructor calls, inefficent loop variable scope?

 
 
ixtahdoom
Guest
Posts: n/a
 
      07-09-2004
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
 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      07-09-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Triple nested loop python (While loop insde of for loop inside ofwhile loop) Isaac Won Python 9 03-04-2013 10:08 AM
Does return-by-value mean extra copies and extra overhead? mathieu C++ 3 09-04-2009 04:25 PM
creating an (inefficent) alternating regular expression from a listof options metaperl.com Python 7 09-18-2008 08:20 PM
A constructor calling another constructor (default constructor)? Generic Usenet Account C++ 10 11-28-2007 04:12 AM
if instance variable get initialize after assigning some values or after constructor then when does static variable get initialize Tony Morris Java 3 02-04-2006 08:39 AM



Advertisments