-
-
Save peczenyj/7301149 to your computer and use it in GitHub Desktop.
Teste comparando Moose (virtual memory size 50204 kb) e Moo (virtual memory size 31364 kb) através do modulo Memory::Usage
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 feature 'say'; | |
| use Memory::Usage; | |
| my $mu = Memory::Usage->new(); | |
| $mu->record('starting work'); | |
| package Foo; | |
| use Moose; | |
| #use Moo; | |
| has 'name' => ( is => 'ro', required => 1 ); | |
| sub run { my ($self) = @_; say $self->name } | |
| 1; | |
| package main; | |
| $mu->record('after create package Foo'); | |
| Foo->new(name => 'bar')->run; | |
| $mu->record('after something_memory_intensive()'); | |
| $mu->dump(); |
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
| $ perl a.pl | |
| bar | |
| time vsz ( diff) rss ( diff) shared ( diff) code ( diff) data ( diff) | |
| 0 28468 ( 28468) 4028 ( 4028) 1892 ( 1892) 1256 ( 1256) 2632 ( 2632) starting work | |
| 0 31236 ( 2768) 4876 ( 848) 1936 ( 44) 1256 ( 0) 3292 ( 660) after create package Foo | |
| 0 31364 ( 128) 5064 ( 188) 1956 ( 20) 1256 ( 0) 3420 ( 128) after something_memory_intensive() | |
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
| tpecze-@tpecze-desktop:~$ perl a.pl | |
| bar | |
| time vsz ( diff) rss ( diff) shared ( diff) code ( diff) data ( diff) | |
| 0 50204 ( 50204) 13448 ( 13448) 2084 ( 2084) 1256 ( 1256) 11624 ( 11624) starting work | |
| 0 50204 ( 0) 13448 ( 0) 2084 ( 0) 1256 ( 0) 11624 ( 0) after create package Foo | |
| 0 50204 ( 0) 13448 ( 0) 2084 ( 0) 1256 ( 0) 11624 ( 0) after something_memory_intensive() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment