Skip to content

Instantly share code, notes, and snippets.

@konobi
Created February 18, 2010 00:08
Show Gist options
  • Save konobi/307168 to your computer and use it in GitHub Desktop.
Save konobi/307168 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use JavaScript;
my @items = map { sub { } } (0..99);
my $things = 20_000;
my $runtime = JavaScript::Runtime->new( (1024 ** 2) * 2);
while($things--) {
my $context = $runtime->create_context;
my $i = 0;
for(@items){
$context->bind_value("hehe_$i" => $_);
$i++;
}
if(!($things % 100)){
my $size = `ps -o rss -p $$`;
chomp($size);
$size =~ s/[^\n]+\n//ms;
my $num = sprintf('%8d', (20_000 - $things));
my $s = sprintf('%20d', $size);
print "size after $num runs is: $s bytes\n";
}
}
size after 0 runs is: 3876 bytes
size after 200 runs is: 10180 bytes
size after 400 runs is: 16464 bytes
size after 600 runs is: 22740 bytes
size after 800 runs is: 29028 bytes
size after 1000 runs is: 35296 bytes
size after 1200 runs is: 41580 bytes
size after 1400 runs is: 47868 bytes
size after 1600 runs is: 54152 bytes
size after 1800 runs is: 60432 bytes
size after 2000 runs is: 66720 bytes
size after 2200 runs is: 72996 bytes
size after 2400 runs is: 79280 bytes
size after 2600 runs is: 85564 bytes
size after 2800 runs is: 91856 bytes
size after 3000 runs is: 98128 bytes
size after 3200 runs is: 104412 bytes
size after 3400 runs is: 110688 bytes
size after 3600 runs is: 116976 bytes
size after 3800 runs is: 123244 bytes
size after 4000 runs is: 129532 bytes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment