Skip to content

Instantly share code, notes, and snippets.

@bokutin
Created May 26, 2012 16:53
Show Gist options
  • Save bokutin/2794597 to your computer and use it in GitHub Desktop.
Save bokutin/2794597 to your computer and use it in GitHub Desktop.
気になっていたMasonのメソッドインポートについて。+Mojo::Templateの比較。
#!/usr/bin/env perl
use lib "/Users/bokutin/git/Foo/lib";
use Modern::Perl;
use IO::All;
use Mason;
my $seq = 0;
sub _mem {
say "SEQ: $seq";
my @lines = `ps auwxxxx | grep '[0-9] perl ./mason.pl'`;
die unless @lines == 1;
# bokutin 30377 2.2 0.0 2436272 2040 s009 S+ 3:15AM 0:00.03 perl ./lesson-eval.pl
#$lines[0];
my @columns = split(/\s+/, $lines[0]);
my $rss = $columns[5];
"RSS: $rss";
}
my $mason = Mason->new(
comp_root => "mason",
data_dir => "data",
plugins => [
#'+Foo::Mason::Plugin::Global',
],
);
say _mem();
while (1) {
for (1..200) {
$seq++;
io("mason/$seq.mc")->print(rand);
my $compc = $mason->load("/$seq.mc");
}
say _mem();
exit if $seq >= 1000;
#sleep 1;
#$seq = 0;
}
# with Foo::Mason::Plugin::Global
#foil bokutin % time ./mason.pl
#SEQ: 0
#RSS: 23016
#SEQ: 200
#RSS: 50524
#SEQ: 400
#RSS: 66156
#SEQ: 600
#RSS: 82432
#SEQ: 800
#RSS: 97996
#SEQ: 1000
#RSS: 113612
#./mason.pl 21.55s user 1.25s system 95% cpu 23.810 total
# without Foo::Mason::Plugin::Global
#foil bokutin % time ./mason.pl
#SEQ: 0
#RSS: 22936
#SEQ: 200
#RSS: 42944
#SEQ: 400
#RSS: 61152
#SEQ: 600
#RSS: 79676
#SEQ: 800
#RSS: 97544
#SEQ: 1000
#RSS: 115364
#./mason.pl 13.88s user 1.19s system 96% cpu 15.677 total
# .mcにがっつりメソッドをインポートした場合、メモリはそうでもないが、CPUはけっこう喰う。
# Mojo::Templateもデフォルトのヘルパーで、かなりメソッドをインポートしてる。
# Masonがヘビーと思いきや、Mojo::Templateも同様に喰ってる。
# .mcはクラス構成で、.epはそうではないが、この違いはそんなにメモリとCPUに影響していないようだ。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment