in reply to Re^3: control-C to "jumpstart" windows process
in thread control-C to "jumpstart" windows process

Note that output to STDOUT defaults to "line-buffered" mode (except on older versions of Win32 Perl where the default was unbuffered), so this would only apply to a single line of output (based on "\n", not a single row of the terminal window).

- tye        

  • Comment on Re^4: control-C to "jumpstart" windows process (line)

Replies are listed 'Best First'.
Re^5: control-C to "jumpstart" windows process (line)
by BrowserUk (Patriarch) on Oct 18, 2006 at 16:53 UTC

    Right. I often added debug out using printf "\r%d\t", $loopVariable unless $loopVariable % 1000, but if STDOUT is buffered, then you have to wait for the buffer to fill before you "see" the first output, and then it increments in leaps and bounds. You can see this with:

    c:\test>perl -lwe" Win32::Sleep( 10 ),printf qq[\r%d\t], $_ for 1 .. 1 +e6"

    Which appears to display (overlaid of course):

    841 1550 2232 2915 ...

    Update: Once you get to 4-digit numbers, the interval is 682. With 4-digits, "\r" & "\t", that is 6 * 682 = 4092. A 4kb buffer.

    Whereas if you disable the buffering

    c:\test>perl -lwe"$|=1;Win32::Sleep( 10 ),printf qq[\r%d\t], $_ for 1 +.. 1e6"

    You see the number increment from 1, quickly and continuously.

    I guess the buffering doesn't consider "\r" as a line ending -- probably rightly. It is useful for monitoring the progress of long running processes. Leaving the buffering enabled means that the IO has a negligable effect upon the speed of the code, and has the beneficial side effect that I can 'pause' and 'resume' the long running process by using the left and right mouse buttons alternately. Mouse equivalent of ^S.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.