timing 4 iterations of bare, memo… bare: 533 wallclock secs ( 0.70 usr + 0.65 sys = 1.35 CPU) memo: 11 wallclock secs ( 0.28 usr + 0.01 sys = 0.29 CPU) (warning: too few iterations for a reliable count) Four iterations is just enough to smooth out any discrepancies caused by random fluctuations, but the memoized chunk still executes fast enough to cause Benchmarkto warn us. In this case, the point has been already made. Do everything possible in Perl rather than calling external programs. Calling out to an external program may be de rigueur in shell scripts, but it costs time (spawning another process) that you often don’t need to expend in a Perl script. There is no need to call awk, sed, cut, head, grep, or similar text filters unless you’re not under time pressure and it happens to read better. Be aware of where the dividing line lies, though. While you can use modules to send e-mail for you, opening a pipe to a mail program that takes care of queuing it is likely to be both faster and easier to read. 11.3.2 Improving Memory Usage Just as the main CPU performance improvements are found in loops, the main memory gains are found in large data structures, so focus on how big your arrays and hashes get. Don’t try to economize by using scalars to save the data instead; that takes up even more space because of the overhead attached to any variable in Perl. Prefer hashes to scalars and arrays to hashes; here’s why: #!/usr/bin/perl -wl sub procsize { (split /s+/, `ps -lp $$ | tail -1`)[9]; # May not be 9 on your system } sub randstring { join ‘’, map chr rand 255, 1..100 } my $base = procsize(); eval “$$_ = randstring” for ‘aaa’ .. ‘zzz’; print “Scalars: “, procsize() - $base; $base = procsize; $hash{$_} = randstring for ‘aaa’ .. ‘zzz’; print “Hash : “, procsize() - $base; $base = procsize; push @array, randstring for ‘aaa’ .. ‘zzz’;
Note: If you are looking for best hosting provider to host and run your tomcat application check Astra tomcat hosting services