in reply to Slow GC after Scalar::Util::weaken

Same results here. Different architecture.

This is perl, v5.8.8 built for PA-RISC2.0

With weaken() call:

1274473378 test 0: main start 1274473378 test 1: func start 1274473380 test 2: func end 1274473443 test 3: main end

Without weaken() call:

1274473556 test 0: main start 1274473556 test 1: func start 1274473558 test 2: func end 1274473558 test 3: main end

Run multiple times with similar results.

--MidLifeXis

Replies are listed 'Best First'.
Re^2: Slow GC after Scalar::Util::weaken
by MidLifeXis (Monsignor) on Jun 03, 2010 at 16:06 UTC

    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