biohisham has asked for the wisdom of the Perl Monks concerning the following question:
andCASE1: my @result = map $_*2, @list;
a meagre increase in "@result" size was reported-168 bytes, i.e. only 8 bytes when@result = join (',',@result);
and @result = join (',',@result); but when I removed the lineCASE2: my @result = map $_*55, @list;
I got "@result" size increasing to 290 in the first case and 296 in the second case. Here is my Code, you can change the line 6 to map $_x-> (x=any number) to appreciate this@result = join (',',@result);
#!/usr/local/bin/perl use strict; use warnings; use Devel::Size qw(size total_size); my @list = qw(1 2 3 4); my @result = map $_*55, @list; @list = join(',',@list); #@result = join (',',@result); print qq(the size of "@list" is: ).total_size(\@list). " Bytes\n"; print qq(the size of "@result" is: ).total_size(\@result)." Bytes\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Memory tip
by jrsimmon (Hermit) on Jun 30, 2009 at 16:14 UTC | |
by biohisham (Priest) on Jun 30, 2009 at 16:38 UTC | |
by jrsimmon (Hermit) on Jun 30, 2009 at 17:09 UTC | |
by SuicideJunkie (Vicar) on Jun 30, 2009 at 18:08 UTC | |
|
Re: Memory tip
by ikegami (Patriarch) on Jun 30, 2009 at 19:08 UTC | |
|
Re: Memory tip
by cdarke (Prior) on Jun 30, 2009 at 18:19 UTC |