1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#!/usr/bin/perl
BEGIN{
print "Content-type: text/plainnn";
open(STDERR, ">&STDOUT");
$|=1;
}
use Benchmark;
$count = 1000;
$cnt = 100;
$dat1 = "reftest1.txt";
$dat2 = "reftest2.txt";
srand;
for(0 .. $cnt){
@nums[$_] = rand;
}
open(OUT, "> $dat1");
close(OUT);
open(OUT, "> $dat2");
close(OUT);
sleep 1;
@t = timethese($count, {
'Refuse' => '&use_ref;',
'RefNouse' => '&nouse_ref;',
});
exit(0);
sub use_ref{
my $r_nums;
$r_nums = @nums;
open(OUT, ">> $dat1");
foreach(@$r_nums){
print OUT "$_n";
}
close(OUT);
}
sub nouse_ref{
my @n_nums;
@n_nums = @nums;
open(OUT, ">> $dat2");
foreach(@n_nums){
print OUT "$_n";
}
close(OUT);
}
|