in reply to Re: Auto-filling an array
in thread Auto-filling an array
I was very intrigued by ikegami's post, so I went ahead and benchmarked the two approaches:
Where would I be without Benchmark?use Benchmark 'cmpthese'; cmpthese( -1, { x => sub { my @list = ( 'N/A' ) x 14 }, push => sub { my @list; push @list, $_ for 1 .. 14 } } ); Rate times push x 89321/s -- -23% push 115925/s 30% --
the lowliest monk
|
|---|