I am working on a perl program that writes data to a cf card. I am using sysopen, sysseek, and syswrite. I am currently doing some speed testing before I decide the best way to approach this. I am having my program write 100mb tot he cf and then quit, it notifies me of progress as it goes. It seems to write the full 100mb, then delay for a long time, the whole operation takes ~38 seconds, but it seems to finish after 10-15 seconds then sit for the rest of it. I tried the same thing w/ a usb drive that had a light indicating usage, the light kept going.
I know that in buffered read/writes the data is actually put in memory then synced to disk when finished or when memory pressure requires.... however I was under the impression from google searches that sysread and syswrite were not buffered, therefore I expect my progress to be progress of the data written to the drive, not the progress of data being queued to enter the drive.
If anyone can enlighten me that would help. Also if anyone can give me a way to truely see the real progress (I am trying to get it to print an MiB per second here.) that would be great.
Here is the relivant code:
sysopen(DEV, "/dev/sdc1", O_RDWR);
$Size = sysseek(DEV,0,2);
print("Size: $Size\n");
sysseek(DEV,0,0);
my $KCounter = 0;
my $MCounter = 0;
my $Temp;
while (1)
{
syswrite(DEV, 'L' x 1024, 1024);
$Temp = sysseek(DEV,0,1);
if ($Temp == $Size)
{
print("\nEND\n");
close(DEV);
exit(0);
}
$Temp = ($Temp / 1024) / 1024;
printf("\r %f MiB", $Temp);
if ($Temp >= 100)
{
print("\n");
close(DEV);
exit(0);
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.