#!/usr/bin/perl use 5.010; use strict; use warnings; use autodie; use Devel::Size qw< total_size >; sub size (&@) { my ($code, $count, $name) = @_; my @test; push @test, $code->($_) for 1..$count; my $full = total_size(\@test); splice @test, 0, @test; my $empty = total_size(\@test); say "\n$name\nfull: $full\nempty: $empty\nratio: ", $empty/$full; } size { bless {} } 100_000, "object"; size { 1 } 100_000, "integer"; size { 3.14159 } 100_000, "number"; size { 'a' } 100_000, "single character string"; size {'a' x 10} 100_000, "string (10)"; size {'a' x 100} 100_000, "string (100)"; size {'a' x 1_000} 100_000, "string (1_000)";