Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Perl -de1 weirdness.

by BrowserUk (Patriarch)
on Jul 19, 2004 at 18:41 UTC ( [id://375642]=perlquestion: print w/replies, xml ) Need Help??

BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:

Has anyone an explaination for why I get such different results from running the same piece of code as a one-liner (or in a program) and running it under the debugger?

P:\test>perl -MTime::HiRes=gettimeofday -le"print scalar gettimeofday( +) for 1 .. 10" 1090261997.71904 1090261997.71921 1090261997.71944 1090261997.71951 1090261997.71957 1090261997.71964 1090261997.7197 1090261997.71976 1090261997.71982 1090261997.71989 P:\test>perl -de1 perldb: Must not source insecure rcfile ./perldb.ini. You or the superuser must be the owner, and it must not be writable by anyone but its owner. Loading DB routines from perl5db.pl version 1.25 Editor support available. Enter h or `h h' for help, or `perldoc perldebug' for more help. main::(-e:1): 1 DB<1> use Time::HiRes qw[gettimeofday]; DB<3> print scalar gettimeofday(), $/ for 1 .. 100; 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.89063 1090262293.92188 1090262293.92188 1090262293.92188 1090262293.92188 1090262293.92188 1090262293.92188 1090262293.92188 1090262293.92188 1090262293.92188 1090262293.92188 1090262293.95313 1090262293.95313 1090262293.95313 [SNIP]

I am at a complete loss to understand why the resolution would become so "blocky" under the debugger?


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon

Replies are listed 'Best First'.
Re: Perl -de1 weirdness.
by Fletch (Bishop) on Jul 19, 2004 at 18:48 UTC

    I don't know why you're getting this exact behavior, but given that the debugger does affect the way perl runs (inserting breakpoints and what not into the normal op tree flow) it's not inconceivable that it would throw timing sensitive code off at least a bit.

      I agree the debugger will likely run the code more slowly, but that means that the values from gettimeofday() should be more widely spaced, not grouped together the way they are.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
      "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon
Re: Perl -de1 weirdness. (path)
by tye (Sage) on Jul 19, 2004 at 18:52 UTC

    My guess is that print $INC{'Time/HiRes.pm'} will show differently (not sure why, though).

    - tye        

      Good thought, but no.

      P:\test>perl -MTime::HiRes=gettimeofday -le"print $INC{'Time/HiRes.pm' +}" c:/Perl/lib/Time/HiRes.pm P:\test>perl -de1 perldb: Must not source insecure rcfile ./perldb.ini. You or the superuser must be the owner, and it must not be writable by anyone but its owner. Loading DB routines from perl5db.pl version 1.25 Editor support available. Enter h or `h h' for help, or `perldoc perldebug' for more help. main::(-e:1): 1 DB<1> use Time::HiRes qw[gettimeofday]; DB<2> print $INC{'Time/HiRes.pm'} c:/Perl/lib/Time/HiRes.pm DB<3>

      I also tried to verify that the import was working properly, and it seems to be:

      DB<4> print \&GLOBAL::CORE::gettimeofday, $/, \&main::gettimeofday, +$/, \&Time::HiRes::gettimeofday CODE(0x1b28118) CODE(0x1a7e034) CODE(0x1a7e034) DB<5> print __PACKAGE__ main

      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
      "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon
Re: Perl -de1 weirdness.
by kvale (Monsignor) on Jul 19, 2004 at 20:37 UTC
    Under linux 2.4.xx, perl 5.8.0, there seems to be no clustering of times:
    1002% perl -MTime::HiRes=gettimeofday -le"print scalar gettimeofday() +for 1..10;" 1090268974.51822 1090268974.5186 1090268974.51873 1090268974.51886 1090268974.51899 1090268974.51911 1090268974.51924 1090268974.51936 1090268974.51949 1090268974.51961 1003% perl -de1 Loading DB routines from perl5db.pl version 1.19 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 1 DB<1> use Time::HiRes qw[gettimeofday]; DB<2> print scalar gettimeofday(), $/ for 1 .. 10; 1090269029.69885 1090269029.69905 1090269029.69912 1090269029.6992 1090269029.6993 1090269029.69937 1090269029.69944 1090269029.69951 1090269029.69959 1090269029.69966
    Perhaps the problem can be narrowed to an interaction with the perl debugger and a Windows OS.

    -Mark

      Indeed.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
      "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon

        BTW, I get the lower-resolution results even w/o the debugger (but I've got 5.6.0 here).

        - tye        

Re: Perl -de1 weirdness.
by dave_the_m (Monsignor) on Jul 19, 2004 at 19:18 UTC
    On Linux, 5.8.0 and 5.8.4, under the debugger I get different times for each gettimeofday().

    Dave.

Re: Perl -de1 weirdness.
by keszler (Priest) on Jul 19, 2004 at 19:24 UTC
    Given the "P:\test>perl" I would think the blockiness comes from Windows doing something else, causing Perl to wait.

    It might be interesting to run under the debugger in several DOS windows: set each to loop long enough that you can switch windows and start the others.

    Send the output to file, process with "uniq".

    Append a tag (a, b, c...) to each line, merge and sort the files. I'd guess the uniq'd, merged, sorted file would be similarly blocky, but that the lines would be close to a, b, c order.

      Please note that both tests are running on the same system, using the same version of perl. The *only* difference is the use of the perl debugger.

      Besides which, if it were "windows making perl wait", the times would get spread wider apart, not grouped together in bunches. The latter effect suggests that perl is calling gettimeofday() more frequently that the timer is running.

      Given the timer is running 3,579,545 times a second, to produce the list of 30 consequetively identical times, The debugger would have to be running the loop 90 million times a second. Which would be nice, but I think we may have to wait for P7 to achieve that kind of performance :)


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
      "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://375642]
Approved by kvale
Front-paged by calin
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-25 15:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found