Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: Re: Re: Re: Idiomatic optimizations

by Juerd (Abbot)
on May 01, 2002 at 19:05 UTC ( #163343=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Re: Re: Idiomatic optimizations
in thread Idiomatic optimizations

afterall is it not true that Deparse is not guaranteed to reconstruct things exactly

It is true that Deparse is not guaranteed to reconstruct things exactly. That's why I did use B::Concise, not B::Deparse. It prints the generated bytecode in a semi-readable way, it does not re-construct Perl code.

The bytecode isn't "supposedly" the same, it IS the same. You could use B::Bytecode to get the raw bytecode (Can't paste because of its binary format), and you could use diff to check their being equivalent. Only compile-time can differ with single/double quotes, so had you benchmarked eval q/$foo = 'foo'/ versus eval q/$foo = "foo"/, you could have gotten some difference. Run-time can, as far as I can see with all the nice tools that let you dig into the generated bytecode, not be different for "foo" versus 'foo', unless when they're evaluated in different circumstances. A load of 0.00 does not mean your system is doing absolutely nothing, as the number is the _average_ number of instructions waiting in a _queue_. If your system is capable of handling simple instructions immediately, you can have a somewhat loaded system with a 0.00 "load average" number.

This indeed does not give any information as to why you got these strange - and as far as I can test impossible - results, but as all my tests (and not only mine) on different systems tell me that "foo" versus 'foo' is a tie, I think you shouldn't trust your benchmark results. Have you been benchmarking using eval STRING, or anything else that makes difference on run-time?

- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.


Comment on Re: Re: Re: Re: Re: Idiomatic optimizations
Re6: Idiomatic optimizations
by belg4mit (Prior) on May 01, 2002 at 20:50 UTC
    The system was idle, trust me, nothing happening. And no, no evals on my part. I simply cut and paste the benchmarking code used by BlueLines HOWEVER, scrutinizing the Benchmark code reveals that *it* in fact string evals.

    --
    perl -pew "s/\b;([mnst])/'$1/g"

      HOWEVER, scrutinizing the Benchmark code reveals that *it* in fact string evals.

      I don't see how it can possibly get something useful out of a sub reference's stringification, but I'm too lazy to look at Benchmark's source. Let's try something different:

      #!/usr/bin/perl -w use Benchmark qw(cmpthese); sub single { $foo = 'foo' } sub double { $foo = "foo" } cmpthese (10000000, { single => sub { single() }, double => sub { double() } });
      What does that show on your system?

      - Yes, I reinvent wheels.
      - Spam: Visit eurotraQ.
      

        It yields a negligible difference 1-3% which I would attribute to system noise. Interestingly(?) it takes much no longer to run, or at least reports more wallclock seconds (15-19 vs 2 or 3 of the other (although it was obviously longer than that)).

        --
        perl -pew "s/\b;([mnst])/'$1/g"

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://163343]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2014-09-19 17:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (143 votes), past polls