| 1 | # | ||||||||||
| 2 | # This file is part of Devel-PatchPerl-Plugin-BenchmarkVirtualError | ||||||||||
| 3 | # | ||||||||||
| 4 | # This software is Copyright (c) 2015 by DreamHost, Inc. | ||||||||||
| 5 | # | ||||||||||
| 6 | # This is free software, licensed under: | ||||||||||
| 7 | # | ||||||||||
| 8 | # The GNU Lesser General Public License, Version 2.1, February 1999 | ||||||||||
| 9 | # | ||||||||||
| 10 | package Devel::PatchPerl::Plugin::BenchmarkVirtualError; | ||||||||||
| 11 | 1 | our $AUTHORITY = 'cpan:RSRCHBOY'; | |||||||||
| 12 | # git description: bfb5e4a | ||||||||||
| 13 | 1 | $Devel::PatchPerl::Plugin::BenchmarkVirtualError::VERSION = '0.001'; | |||||||||
| 14 | |||||||||||
| 15 | # ABSTRACT: Avoid failures on Benchmark.t when building under certain virtual machines | ||||||||||
| 16 | |||||||||||
| 17 | 1 | ▶ | use base 'Devel::PatchPerl'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | |||||||||||
| 19 | 0 | ▶ | sub patchperl { | ||||||||
|
Subroutine
patchperl: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 20 | 0 | my $class = shift; | |||||||||
| 21 | 0 | my %args = @_; | |||||||||
| 22 | 0 | my ($vers, $source, $patch_exe) = @args{qw(version source patchexe)}; | |||||||||
| 23 | 0 | for my $p ( grep { Devel::PatchPerl::_is( $_->{perl}, $vers ) } @Devel::PatchPerl::patch ) { | |||||||||
| 24 | 0 | for my $s (@{$p->{subs}}) { | |||||||||
| 25 | 0 | my ($sub, @args) = @$s; | |||||||||
| 26 | 0 | ▶ | push @args, $vers unless scalar @args; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | 0 | $sub->(@args); | |||||||||
| 28 | } | ||||||||||
| 29 | } | ||||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | |||||||||||
| 33 | package | ||||||||||
| 34 | Devel::PatchPerl; | ||||||||||
| 35 | |||||||||||
| 36 | 1 | ▶ | use vars '@patch'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 37 | |||||||||||
| 38 | 1 | @patch = ( | |||||||||
| 39 | { | ||||||||||
| 40 | perl => [ qr/^5\.(1|20)/ ], | ||||||||||
| 41 | subs => [ [\&_patch_benchmarkvirtualerror] ], | ||||||||||
| 42 | }, | ||||||||||
| 43 | ); | ||||||||||
| 44 | |||||||||||
| 45 | 0 | ▶ | sub _patch_benchmarkvirtualerror { | ||||||||
|
Subroutine
_patch_benchmarkvirtualerror: not called CC=1 SCAR=6.9
| |||||||||||
| 46 | |||||||||||
| 47 | 0 | _patch(<<'EOP'); | |||||||||
| 48 | diff --git lib/Benchmark.pm lib/Benchmark.pm | ||||||||||
| 49 | index 9a43a2b..73b3211 100644 | ||||||||||
| 50 | --- lib/Benchmark.pm | ||||||||||
| 51 | +++ lib/Benchmark.pm | ||||||||||
| 52 | @@ -700,8 +700,18 @@ sub runloop { | ||||||||||
| 53 | # getting a too low initial $n in the initial, 'find the minimum' loop | ||||||||||
| 54 | # in &countit. This, in turn, can reduce the number of calls to | ||||||||||
| 55 | # &runloop a lot, and thus reduce additive errors. | ||||||||||
| 56 | + # | ||||||||||
| 57 | + # Note that its possible for the act of reading the system clock to | ||||||||||
| 58 | + # burn lots of system CPU while we burn very little user clock in the | ||||||||||
| 59 | + # busy loop, which can cause the loop to run for a very long wall time. | ||||||||||
| 60 | + # So gradually ramp up the duration of the loop. See RT #122003 | ||||||||||
| 61 | + # | ||||||||||
| 62 | my $tbase = Benchmark->new(0)->[1]; | ||||||||||
| 63 | - while ( ( $t0 = Benchmark->new(0) )->[1] == $tbase ) {} ; | ||||||||||
| 64 | + my $limit = 1; | ||||||||||
| 65 | + while ( ( $t0 = Benchmark->new(0) )->[1] == $tbase ) { | ||||||||||
| 66 | + for (my $i=0; $i < $limit; $i++) { my $x = $i / 1.5 } # burn user CPU | ||||||||||
| 67 | + $limit *= 1.1; | ||||||||||
| 68 | + } | ||||||||||
| 69 | $subref->(); | ||||||||||
| 70 | $t1 = Benchmark->new($n); | ||||||||||
| 71 | $td = &timediff($t1, $t0); | ||||||||||
| 72 | EOP | ||||||||||
| 73 | } | ||||||||||
| 74 | |||||||||||
| 75 | 1 | !!42; | |||||||||
| 76 | |||||||||||
| 77 | __END__ | ||||||||||