Created
July 25, 2014 17:34
-
-
Save nnutter/ccceeea53eb239c7ef91 to your computer and use it in GitHub Desktop.
size.pl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use strict; | |
| use warnings; | |
| use Genome; | |
| use Devel::Size qw(size total_size); | |
| use List::Util qw(sum); | |
| use Scalar::Util qw(weaken); | |
| my $list = []; | |
| my $hash = {}; | |
| my $model = Genome::Model->get(name => 'apipe-test-reference-alignment'); | |
| my $i = $ARGV[0] || 10; | |
| my $j = $ARGV[1] || 10; | |
| for my $class (1..$i) { | |
| for my $id (1..$j) { | |
| { | |
| my $ref = $model; | |
| weaken($ref); | |
| push @$list, $ref; | |
| } { | |
| $hash->{$class}->{$id} = undef; | |
| } | |
| } | |
| } | |
| my $n = @$list; | |
| my $hash_size = total_size($hash); | |
| my $list_size = size($list) + sum map { size \$_ } @$list; | |
| printf("N = %d\n", $n); | |
| printf("Hash Size: %d\n", $hash_size); | |
| printf("List Size: %d\n", $list_size); | |
| printf("Hash/List: %0.2f%%\n", $hash_size/$list_size * 100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment