Last active
August 29, 2015 13:55
-
-
Save hirose31/8703122 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Data::Validator; | |
memory_usage(); | |
for (1 .. 200) { | |
foo(name => 'Ichiro', age => 18); | |
foo(name => 'Jiro', age => 69); | |
} | |
memory_usage(); | |
for (1 .. 200) { | |
foo(name => 'Ichiro', age => 18); | |
foo(name => 'Jiro', age => 69); | |
} | |
memory_usage(); | |
sub foo { | |
my $rule = Data::Validator->new( | |
name => 'Str', | |
age => 'Int', | |
)->with(qw(NoThrow AllowExtra)); | |
my($p) = $rule->validate(@_); | |
warn(join("\n", map {$_->{message}} @{$rule->clear_errors})) | |
if $rule->has_errors; | |
# printf "%s (%d)\n", $p->{name}, $p->{age}; | |
} | |
sub memory_usage { system("ps uw -p $$") } | |
__END__ | |
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | |
hirose31 27896 0.0 0.0 25888 4476 pts/24 S+ 14:51 0:00 perl ./dval-leak.pl | |
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | |
hirose31 27896 0.0 0.0 37508 16264 pts/24 S+ 14:51 0:00 perl ./dval-leak.pl | |
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | |
hirose31 27896 0.0 0.1 48860 27516 pts/24 S+ 14:51 0:00 perl ./dval-leak.pl |
This file contains 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
package Foo; | |
use Mouse::Role; | |
package main; | |
my $o = bless {}; | |
memory_usage(); | |
for (1 .. 200) { Mouse::Util::apply_all_roles($o, 'Foo') } | |
memory_usage(); | |
for (1 .. 200) { Mouse::Util::apply_all_roles($o, 'Foo') } | |
memory_usage(); | |
sub memory_usage { system("ps uw -p $$") } | |
__END__ | |
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | |
hirose31 27843 0.0 0.0 25756 4464 pts/24 S+ 14:48 0:00 perl ./mouse-leak.pl | |
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | |
hirose31 27843 0.0 0.0 29452 8136 pts/24 S+ 14:48 0:00 perl ./mouse-leak.pl | |
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | |
hirose31 27843 0.0 0.1 37900 16660 pts/24 S+ 14:48 0:00 perl ./mouse-leak.pl | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment