in reply to Re: Using a Variable Mutipule times(with different data)
in thread Using a Variable Mutipule times(with different data)
And it gives:#!/usr/bin/perl -w use strict; use Benchmark; timethese(1000, { 'global' => '&global', 'local' => '&local' }); sub global { my %hash; for(1..100) { for(1..10) { $hash{rand(100)} = 123; }; } %hash=(); } sub local { for(1..100) { my %hash; for(1..10) { $hash{rand(100)} = 123; }; } }
so it seems like there is not much difference.Benchmark: timing 1000 iterations of global, local... global: 14 wallclock secs (13.47 usr + 0.01 sys = 13.48 CPU) local: 14 wallclock secs (13.33 usr + 0.02 sys = 13.35 CPU)
|
|---|