210
|
1 #!/usr/bin/perl
|
|
2 use strict;
|
395
|
3
|
407
|
4 use Time::HiRes qw(gettimeofday tv_interval);
|
|
5 use constant COUNT => 20000000;
|
|
6
|
|
7 my $t;
|
|
8
|
|
9 $t = [gettimeofday];
|
|
10
|
|
11 for ( my $i = 0 ; $i < COUNT ; $i++ ) {
|
|
12 my $o = [];
|
|
13 $o->[0] = 10;
|
|
14 $o->[20] = 11;
|
|
15 }
|
|
16
|
|
17 print "Arrays: ", tv_interval( $t, [gettimeofday] ), "\n";
|
210
|
18
|
407
|
19 $t = [gettimeofday];
|
|
20
|
395
|
21
|
407
|
22 for ( my $i = 0 ; $i < COUNT ; $i++ ) {
|
|
23 my $o = {};
|
|
24 $o->{a} = 10;
|
|
25 $o->{b} = 11;
|
|
26 }
|
406
|
27
|
407
|
28 print "Hashes: ", tv_interval( $t, [gettimeofday] ), "\n";
|
|
29
|
|
30
|
|
31
|
|
32 1;
|