File: mem.t

package info (click to toggle)
libutil-h2o-perl 0.24-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 140 kB
  • sloc: perl: 1,097; makefile: 2
file content (29 lines) | stat: -rwxr-xr-x 961 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env perl
use warnings;
use strict;
use Test::More tests=>4;
use Util::H2O;

## no critic (ProhibitBacktickOperators)

my ($initial) = `ps -orss $$`=~/\bRSS\s+(\d+)\b/;

for (1..1000) { my $h = { map {$_=>$_} 1..1000 } }

my ($normal) = `ps -orss $$`=~/RSS\s+(\d+)/;
ok $normal < $initial+1000, 'memory growth after normal hashrefs ('.($normal-$initial).'<1000)';

for (1..1000) { h2o { map {$_=>$_} 1..1000 } }

my ($after) = `ps -orss $$`=~/RSS\s+(\d+)/;
ok $after < $normal+2500, 'memory growth after h2o hashrefs ('.($after-$normal).'<2500)';

for (1..1000) { h2o(-meth, { map {$_=>sub{$_}} 1..1000 })->$_ }

my ($after2) = `ps -orss $$`=~/RSS\s+(\d+)/;
ok $after2 < $after+500, 'memory growth after h2o with methods ('.($after2-$after).'<500)';

for (1..100) { h2o -class=>"XYZ$_", { map {$_=>$_} 1..1000 } }

my ($big) = `ps -orss $$`=~/RSS\s+(\d+)/;
ok $big > $after2+40_000, 'memory growth after not cleaning ('.$big.'>'.($after2+40_000).')';