in reply to FILE IO, delay after finish.

Using syswrite over write only means that Perl won't do any buffering. Your operating system will still do buffering, likely until the file gets closed or the process calls exit.

I guess you can only show the "real" progress as the OS claims by waiting until your program finishes and then calculating the throughput.

As an aside, you might want to unbuffer STDOUT so your progress gets displayed:

$|++;

(unless you're already doing that somewhere). If you're concerned about writing speed, I'd try to write larger buffers, maybe something in the range of the cluster size of the hard disk or in the range of half/twice the cache size of the hard disk to maximize the amount of data available for the disk to write.

Replies are listed 'Best First'.
Re^2: FILE IO, delay after finish.
by exodist (Monk) on Jun 16, 2007 at 19:24 UTC
    Well, essentially what I am trying to do is compare continuous write and random write on different media types.
    I also did this to test writing with seeking to different positions first.
    # foreach (1 .. 1024) # { # syswrite(DEV, 'L' x 1024, 1024); # } # $MCounter++; # printf("\r %f MiB", $MCounter); # if ($MCounter >= 100) # { # close(DEV); # exit(0); # } # sysseek(DEV,(1024*1024*2), 1); # print("\nJumping 2mb\n");

    This is giving me frustrating results as my cf card is 100x, my drive is sata, and my usb stick unknown speed.
    Here are the results:
    Continuous write, 100 mb: Image stored on a filesystem: 26.964s 100x CF Card: 36.572s USB Stick: 1m28.938s Disk Partition: 2.599s Random write (write 1mb, skip 2mb, loop) Image: 21.111s CF: 49.917s USB: 1m29.354s Partition: 2.832s

    As predicted the random write took longer... but my understanding was that for short random read/write operations flash media was supposed to be faster because of a hard drives slow seeking. Then again I am addressing a continuous 300mb section, just skiping 2mb each time, so I guess I should re-think this experiment to really jump around both directions....