Sample TAP-ready file:

#!/bin/env perl # Test script for RT 75254 # URL: http://rt.perl.org/rt3/Public/Bug/Display.html?id=75254 # URL: http://www.perlmonks.org/?node_id=841116 use strict; use warnings; use Time::HiRes qw(time); use Test::More; use Scalar::Util qw(weaken); # The ratio of time with weaken vs without for which we test. What is # the performance target? my @timefactors = reverse ( 1.5, 2, 5, 10, 25, 50, 100 ); plan tests => 5 + scalar(@timefactors); my @data = (1, 2, 3); pass("Begin performance test for weaken(): this may take a while."); # Record the time without using weaken() my $withouttime; { my $endtime = &withoutweaken(); my $stoptime = time; $withouttime = $stoptime - $endtime; } pass(sprintf("Time without weaken(): %.2f", $withouttime)); # Record the time using weaken() my $withtime; { my $endtime = &withweaken(); my $stoptime = time; $withtime = $stoptime - $endtime; } pass(sprintf("Time with weaken(): %.2f", $withtime)); my $timeratio = ($withtime / $withouttime); pass(sprintf( "Time Ratio: TIME(with) / TIME(without): %.2f", $timerat +io )); foreach ( @timefactors ) { ok( $timeratio < $_, "Time ratio is < $_" ); } pass("End performance test for weaken()."); sub withweaken { my @h; for (1 .. 200000) { my %hash = (data => \@data); weaken($hash{data}); push @h, \%hash; } return time; } sub withoutweaken { my @h; for (1 .. 200000) { my %hash = (data => \@data); push @h, \%hash; } return time; }

--MidLifeXis


In reply to Re^2: Slow GC after Scalar::Util::weaken by MidLifeXis
in thread Slow GC after Scalar::Util::weaken by jura05

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.