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);
}