develooper Front page | perl.perl5.porters | Postings from October 2014

Re: proposal for performance testing infrastructure

Thread Previous | Thread Next
From:
H.Merijn Brand
Date:
October 15, 2014 06:59
Subject:
Re: proposal for performance testing infrastructure
Message ID:
20141015085903.2503a0d7@pc09.procura.nl
On Tue, 14 Oct 2014 21:00:29 +0100, Dave Mitchell <davem@iabyn.com>
wrote:

> Fourthly, we currently abuse ext/Devel-Peek/t/Peek.t (in a similar manner
> to ext/B/t/optree_concise.t) when we want to check SVs for having
> particular flags set etc. For similar reasons, I propose a new test file,
> t/perf/peek.t say, that will call Dump on an SV of interest, and return a
> hash of 'key = value' pairs; for example 
> 
>     SV = PVAV(0x18a0208) at 0x18c9970
>       REFCNT = 1
>       FLAGS = ()
>       ARRAY = 0x0
>       FILL = -1
>       MAX = -1
>       ARYLEN = 0x0
>       FLAGS = (REAL)
> 
> might be returned as the simple hash
> 
>     {
>         SV     => 'PVAV(0x18a0208) at 0x18c9970',
>         REFCNT => '1',
>         FLAGS  => '()',
>         ARRAY  => '0x0',
>         FILL   => '-1',
>         MAX    => '-1',
>         ARYLEN => '0x0',
>         FLAGS  => '(REAL)',
>     }

I did so in Data::Peek

   DDump ($var [, $dig_level])
       A very useful module when debugging is "Devel::Peek", but is has one
       big disadvantage: it only prints to STDERR, which is not very handy
       when your code wants to inspect variables at a low level.

       Perl itself has "sv_dump ()", which does something similar, but still
       prints to STDERR, and only one level deep.

       "DDump ()" is an attempt to make the innards available to the script
       level with a reasonable level of compatibility. "DDump ()" is context
       sensitive.

       In void context, it behaves exactly like "Perl_sv_dump ()".

       In scalar context, it returns what "Perl_sv_dump ()" would have
       printed.

       In list context, it returns a hash of the variable's properties. In
       this mode you can pass an optional second argument that determines the
       depth of digging.

       Example

         print scalar DDump "abc\x{0a}de\x{20ac}fg"

         SV = PV(0x723250) at 0x8432b0
           REFCNT = 1
           FLAGS = (PADBUSY,PADMY,POK,pPOK,UTF8)
           PV = 0x731ac0 "abc\nde\342\202\254fg"\0 [UTF8 "abc\nde\x{20ac}fg"]
           CUR = 11
           LEN = 16

         my %h = DDump "abc\x{0a}de\x{20ac}fg";
         print DDumper \%h;

         {   CUR              => '11',
             FLAGS            => {
                 PADBUSY          => 1,
                 PADMY            => 1,
                 POK              => 1,
                 UTF8             => 1,
                 pPOK             => 1
                 },
             LEN              => '16',
             PV               => '0x731ac0 "abc\\nde\\342\\202\\254fg"\\0 [UTF8 "abc\\nde\\x{20ac}fg"]',
             REFCNT           => '1',
             sv               => 'PV(0x723250) at 0x8432c0'
             };



-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.19   porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/        http://www.test-smoke.org/
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About