G
Gernot Frisch
Hi,
I want to have a representative information about the read and write
speeds of a drive (cf-card, HDD and RAM-Disk).
I think the buffering of the filesystem must be fooled somehow for my
test program (sorry, uses GetTickCount() == Win32 for Milliseconds)
# # #
// E:\\Temp\\ (HardDisk) Write: 9761.29KB/s, Read: 371794.26KB/s
// R:\\ (RamDrive) Write: 144010.44KB/s, Read: 372827.02KB/s
#include <stdio.h>
#define FBUFSIZ (1024*1024*8) // 8Meg
#define LOOPS 16
#define TESTFILE "R:\\test.txt"
int main(int, char**)
{
char* buffer = new char[FBUFSIZ];
DWORD start, end1, end2;
// make sure memory is there
for(int i=0; i<FBUFSIZ; ++i)
buffer=(char)i;
start = ::GetTickCount();
// Write test
for(int i=0; i<LOOPS; ++i)
{
FILE* pF = fopen(TESTFILE, "wb");
fwrite(buffer, FBUFSIZ, 1, pF);
fclose(pF);
}
end1 = ::GetTickCount();
// Read test
for(int i=0; i<LOOPS; ++i)
{
FILE* pF = fopen(TESTFILE, "rb");
fread(buffer, FBUFSIZ, 1, pF);
fclose(pF);
}
end2 = ::GetTickCount();
printf("Write: %.2fKB/s, Read: %.2fKB/s\n",
(double)FBUFSIZ*LOOPS/(end1-start),
(double)FBUFSIZ*LOOPS/(end2-end1));
buffer[0] = 1;
delete[] buffer;
}
# # #
I want to have a representative information about the read and write
speeds of a drive (cf-card, HDD and RAM-Disk).
I think the buffering of the filesystem must be fooled somehow for my
test program (sorry, uses GetTickCount() == Win32 for Milliseconds)
# # #
// E:\\Temp\\ (HardDisk) Write: 9761.29KB/s, Read: 371794.26KB/s
// R:\\ (RamDrive) Write: 144010.44KB/s, Read: 372827.02KB/s
#include <stdio.h>
#define FBUFSIZ (1024*1024*8) // 8Meg
#define LOOPS 16
#define TESTFILE "R:\\test.txt"
int main(int, char**)
{
char* buffer = new char[FBUFSIZ];
DWORD start, end1, end2;
// make sure memory is there
for(int i=0; i<FBUFSIZ; ++i)
buffer=(char)i;
start = ::GetTickCount();
// Write test
for(int i=0; i<LOOPS; ++i)
{
FILE* pF = fopen(TESTFILE, "wb");
fwrite(buffer, FBUFSIZ, 1, pF);
fclose(pF);
}
end1 = ::GetTickCount();
// Read test
for(int i=0; i<LOOPS; ++i)
{
FILE* pF = fopen(TESTFILE, "rb");
fread(buffer, FBUFSIZ, 1, pF);
fclose(pF);
}
end2 = ::GetTickCount();
printf("Write: %.2fKB/s, Read: %.2fKB/s\n",
(double)FBUFSIZ*LOOPS/(end1-start),
(double)FBUFSIZ*LOOPS/(end2-end1));
buffer[0] = 1;
delete[] buffer;
}
# # #