#!/usr/bin/perl # $Id$ use strict; use Test::More 'no_plan'; use Devel::Size qw(total_size); use Tie::Array::Null; foreach my $size ( 0, 1, 5, 10, 100 ) { report( $size ) } pass(); sub report { my $size = shift; my $object = tie my( @tied_array ), 'Tie::Array::Null', $size; isa_ok( $object, 'Tie::Array::Null' ); my $tied_array_size = total_size( \@tied_array ); my @regular_array = (); print STDERR "\n----Testing for size $size-----\n"; print STDERR "Tied array size before is " . total_size( \@tied_array ) . "\n"; print STDERR "Regular array size before is " . total_size( \@regular_array ) . "\n"; print STDERR "-" x 73, "\n"; printf STDERR "%5s %5s %5s %5s\n", qw(iter tied len reg); for( my $i = 0; $i < 1000; $i++ ) { $tied_array[$i] = 'T'; push @regular_array, 'T'; unless( $i % 100 ) { printf STDERR "%5d %5d %5d %5d\n", $i, total_size( \@tied_array ), total_size( \$object ), total_size( \@regular_array ); } } }