10.42 CPU) Memoizefunction calls with common arguments. Using the CPAN module Memoize(http://search.cpan.org/search?dist=Memoize) by Mark- Jason Dominus to transparently remember the results of any function call gives you an easy way to trade memory for speed. You could do the same thing with slightly less execution overhead in your program by creating appropriate data structures and checking for the existence of an entry there before calling a function, but Memoizeallows you to swap this capability in and out at the cost of a single line, and it can even save the results to disk to make them persistent. We can illustrate this with an example that looks up the canonical Internet host name for various servers. It might be quite common to call gethostbynamefor the same input more than once in, for instance, an application processing log files, and it’s reasonable to assume that within a short period say, a few minutes the results won’t change. Here’s a benchmark: use Benchmark; use Memoize; sub get_host_info { (gethostbyname shift)[0] || ‘undefined’; } sub get_hosts { for (1..shift) { my $true_name = get_host_info “www.$_.com” } } for ‘aaa’ .. ‘abc’; get_hosts(1); # Prime the local cache timethese (4, { bare => q{ get_hosts(10) }, memo => q{ use Memoize; memoize q(get_host_info); get_hosts(10) } }); For benchmark comparison purposes only, we first do a lookup on all the hosts so that the local nameserver has a chance to put the information in its cache. That stops the second benchmark from having an unfair advantage. Then we look up the host information for several hosts 10 times each. The results are:
Note: If you are looking for best hosting provider to host and run your tomcat application check Astra tomcat hosting services