依存モジュールのメモリー測定チェック
さっきのエントリで書いたMakefile.PLのrequiresをチェックして、依存モジュールをuseしたときのメモリ使用量チェックするスクリプト書いてみた。
#!/usr/bin/env perl use strict; use warnings; use Devel::MemUsed; use Module::Depends; my $deps = Module::Depends->new->dist_dir('.')->find_modules; foreach my $module ( keys %{ $deps->requires } ) { my $pid = fork(); if ($pid) { # parent wait(); } elsif ( defined $pid ) { my $memused = Devel::MemUsed->new; eval "use $module"; print "$module -> $memused\n"; exit(); } else { die "fork error : $!"; } }
静的にロードされるモジュールの簡易チェックには十分使えそう。
HTTP::Engineでやってみた例
Scalar::Util -> 5096 HTTP::Headers::Fast -> 196848 File::Copy -> 168088 URI -> 146000 HTTP::Body -> 1928936 File::Spec::Unix -> 84392 Class::Method::Modifiers -> 149416 perl -> 5184 HTTP::Server::Simple -> 871928 Mouse -> 621496 CGI::Simple::Cookie -> 202192
# useだけだと、いくつかのモジュールでエラーなっちゃうけど、Handling面倒なのでそこはパスで...