WinXP -> OpenVMS tests reproduced using C++ test program
BG - Ben Armstrong
BArmstrong at dymaxion.ca
Wed Sep 22 21:01:16 GMT 2004
I have reproduced the same test results as for the ruby test program,
only this time using a C++ port of it. I saw the same samba protocol
pattern of a 1024-byte write followed by one 1-byte write after the
first 64K observed in the packet capture log, and similar performance
numbers. Please ignore the earlier version I posted, as it was buggy,
and use the one below instead. This should work on OpenVMS, Linux and
Windows.
This should settle the question over "what's this ruby thing" now. :)
As before, I have a packet capture log if anyone wants to see it.
-- cut here --
#include <errno.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <time.h>
using namespace std;
int main(int argc, char * argv[]) {
time_t startTime, endTime;
char drive[50];
long int blocks = 10000, blocksize = 1024;
switch (argc) {
case 1:
strcpy(drive, "S:\\");
break;
case 2:
strcpy(drive, argv[1]);
break;
case 3:
strcpy(drive, argv[1]);
blocks = strtol(argv[2], NULL, 10);
if (errno == ERANGE) {
cout << "Invalid # of blocks: " << argv[2] << endl;
cout << " Default of 10000 used." << endl;
blocks = 10000;
}
break;
case 4:
strcpy(drive, argv[1]);
blocks = strtol(argv[2], NULL, 10);
if (errno == ERANGE) {
cout << "Invalid blocks # used: " << argv[2] << endl;
cout << " Default of 10000 used." << endl;
blocks = 10000;
}
blocksize = strtol(argv[3], NULL, 10);
if (errno == ERANGE) {
cout << "Invalid blocksize # used: " << argv[2] << endl;
cout << " Default of 1024 used." << endl;
blocksize = 1024;
}
break;
default:
cout << "Usage: samba_test.exe {drive {blocks {blocksize}}}" << endl;
}
cout << "Generating stats with the following arguments:" << endl;
cout << "Drive: " << drive << endl;
cout << "Blocks: " << blocks << endl;
cout << "Blocksize: " << blocksize << endl;
char * data;
data = new char[blocksize+1];
memset(data, ' ', blocksize+1);
data[blocksize] = '\0';
char dataFile[60];
strcpy(dataFile, drive);
strcat(dataFile, "BENCH.TMP");
ofstream fout;
time(&startTime);
fout.open(dataFile);
if (fout.bad()) {
cout << "Error opening the data file" << endl;
}
for (int i=0; i < blocks; i++) {
fout << data;
}
fout.close();
remove(dataFile);
time(&endTime);
long int elapsed_time = (long) difftime(endTime, startTime),
bytesOut = blocks * blocksize;
cout << "On drive " << drive << " time to write " << bytesOut <<
" bytes = " << elapsed_time << " seconds." << endl;
delete [] data;
return 0;
}
More information about the samba-vms
mailing list