Changeset 24504

Show
Ignore:
Timestamp:
11/20/08 20:23:55 (7 weeks ago)
Author:
daisuke
Message:

ps isn't the best choice, but what the heck.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/DateTime-Lite/trunk/tools/profile/simple_create.pl

    r24501 r24504  
    11use strict; 
    2 use DateTime::Lite; 
     2 
     3my $class = $ENV{DATETIME_CLASS} || 'DateTime::Lite'; 
     4 
     5my $before = get_memory(); 
     6print "memory usage before using $class: $before\n"; 
     7 
     8eval "require $class"; 
    39 
    410for(1..100) { 
    5     DateTime::Lite->new(year => 2000, month => 1, day => 1); 
     11    $class->new(year => 2000, month => 1, day => 1); 
    612} 
     13 
     14my $after = get_memory(); 
     15print "memory usage after using $class: $after\n"; 
     16print "  memory used = ", $after - $before, "\n"; 
     17 
     18sub get_memory { 
     19    my $output = `ps -opid,rss`; 
     20 
     21    foreach (split /\n/, $output) { 
     22        next unless /^\s(\d+)\s+(\d+)/; 
     23        next unless $1 eq $$; 
     24 
     25        return $2; 
     26    } 
     27}