File: zz-stash-xs-leak.t

package info (click to toggle)
libtemplate-perl 2.24-1.2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 8,676 kB
  • ctags: 1,427
  • sloc: perl: 14,535; makefile: 15; sh: 5
file content (55 lines) | stat: -rw-r--r-- 1,443 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#============================================================= -*-perl-*-
#
# t/stash-xs-leak.t
#
# Template script to investigate a leak in the XS Stash
#
# Written by Andy Wardley <abw@wardley.org>
#
# Copyright (C) 1996-2009 Andy Wardley.  All Rights Reserved.
#
# This is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
#========================================================================

use strict;
use warnings;
use lib qw( ./lib ../lib ../blib/lib ../blib/arch ./blib/lib ./blib/arch );
use Template::Constants qw( :status );
use Template;
use Test::More;

my $author = grep(/--abw/, @ARGV);

# belt and braces
unless ($author) {
    plan( skip_all => 'Internal test for abw, add the --abw flag to run' );
}
unless ( $author or $ENV{AUTOMATED_TESTING} or $ENV{RELEASE_TESTING} ) {
    plan( skip_all => "Author tests not required for installation" );
}

require Template::Stash::XS;

my $stash = Template::Stash::XS->new( { x => 10, y => { } } );

my ($a, $b) = (5, 10_000);

print <<EOF;
Use 'top' to monitor the memory consumption.  It should remain static.
(alas, Devel::Mallinfo doesn't seem to work on my Mac)
EOF

while ($a--) {
    my $c = $b;
    print "$a running...\n";
    while ($c--) {
        $stash->get( ['x', 0, 'y', 0] );
        $stash->get( ['x', 0, 'length', 0] );
        $stash->get( ['y', 0, 'length', 0] );
    }
    print "pausing...\n";
    sleep 1;
}