~dexter/parrot-pkg/maverick

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
54
55
56
57
58
59
60
61
#! perl
# Copyright (C) 2001-2006, Parrot Foundation.

=head1 NAME

examples/benchmarks/freeze.pl - Freeze/Thaw Benchmarks

=head1 SYNOPSIS

    % time perl examples/benchmarks/freeze.pl

=head1 DESCRIPTION

Freeze/thaw a C<ResizablePMCArray>. Uses C<Storable> to archive the array.

=cut

use strict;
use warnings;

use Storable qw( freeze thaw dclone );
use Time::HiRes qw( time );

my @a;
my $s = time();
for my $i ( 0 .. 99999 ) {
    push @a, $i;
}
my $e = time();
printf "constr.time %.6f\n", $e - $s;

$s = time();
my $image = freeze( \@a );
$e = time();
printf "freeze time %.6f\n", $e - $s;

$s = time();
my @b = @{ thaw $image };
$e = time();
printf "  thaw time %.6f\n", $e - $s;

#$s = time();
#my $c = dclone \@a;
#$e = time();
#printf " clone time %.6f\n", $e-$s;

print "Image len ", length($image), "\n";
print "array size ", scalar(@b), "\n";

=head1 SEE ALSO

F<examples/benchmarks/freeze.pasm>.

=cut

# Local Variables:
#   mode: cperl
#   cperl-indent-level: 4
#   fill-column: 100
# End:
# vim: expandtab shiftwidth=4: