Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
If I'm not mistaken, the FTP server is usually implemented as a client of the inetd/xinetd daemon. As such, it should not do any socket-level IO, only reading and writing to standard input & standard output.
I do a bit of hobby programming in Ruby which is an interpreted language and therefore relatively slow. As far as I can see it gets the time so quickly that the overhead is irrelevant unless you are trying to measure very short periods (fractions of a millisecond). You can minimize the "cost" of the calculation by downloading a larger block of data - that way the fixed calculation error is spread over more bytes. I was using this method to see how quickly I could send about 4k bytes of data over a USB connection to a FTDI UM245R device.
Data Sent: 210450 bytes in 0.297000 seconds
5.67 Meg bits per seconds
Data Sent: 210450 bytes in 0.297000 seconds
5.67 Meg bits per seconds
Data Sent: 210450 bytes in 0.297000 seconds
5.67 Meg bits per seconds
Data Sent: 210450 bytes in 0.281000 seconds
5.99 Meg bits per seconds
Data Sent: 210450 bytes in 0.297000 seconds
5.67 Meg bits per seconds
Data Sent: 210450 bytes in 0.297000 seconds
5.67 Meg bits per seconds
Data Sent: 210450 bytes in 0.282000 seconds
5.97 Meg bits per seconds
Data Sent: 210450 bytes in 0.282000 seconds
5.97 Meg bits per seconds
Data Sent: 210450 bytes in 0.297000 seconds
5.67 Meg bits per seconds
Data Sent: 210450 bytes in 0.281000 seconds
5.99 Meg bits per seconds
Data Sent: 210450 bytes in 0.297000 seconds
5.67 Meg bits per seconds
Data Sent: 210450 bytes in 0.281000 seconds
5.99 Meg bits per seconds
Data Sent: 210450 bytes in 0.297000 seconds
5.67 Meg bits per seconds
Data Sent: 210450 bytes in 0.281000 seconds
5.99 Meg bits per seconds
Data Sent: 210450 bytes in 0.297000 seconds
5.67 Meg bits per seconds
Data Sent: 210450 bytes in 0.281000 seconds
5.99 Meg bits per seconds
Data Sent: 210450 bytes in 0.297000 seconds
5.67 Meg bits per seconds
//Get the text to send from a file
do{
fgets(finpData, 1023, data_file);
if(!feof(data_file)) {
printf("%s", finpData);
numbytes += strlen(finpData);
fDatalen=strlen(finpData);
finpData[fDatalen-1]=0xd;
finpData[fDatalen]=0xa;
finpData[fDatalen+1]='\0';
strcpy(dtextbuf[prowdtext++], finpData);
}
}while(!feof(data_file));
prowdtextmx=prowdtext;
printf("Document read %d lines\n", prowdtextmx);
//We will continue to run the test as long as "go_again" is == 1. We enter this at the bottom
//of the loop
while(go_again == 1) {
//Get starting time
GetLocalTime(<);
//the vairable "timestosend" is set to 30
for(i = 0; i < timestosend; i++){
for(prowdtext=0; prowdtext < prowdtextmx; prowdtext++) {
send(sock, dtextbuf[prowdtext], strlen(dtextbuf[prowdtext]), 0);
}
}
//Get ending time
GetLocalTime(<1);
//Calculate time elapsed
et=(((int)lt1.wSecond + .001*(int)lt1.wMilliseconds) -((int)lt.wSecond + .001*(int)lt.wMilliseconds));
//Print the results & save to results file
printf("Data Sent: %d bytes in %f seconds\n", i*numbytes, et);
printf("%2.2f Meg bits per seconds\n", 8*(i*numbytes/et)/1000000);
fprintf(results_file, "Data Sent: %d bytes in %f seconds\n", i*numbytes, et);
fprintf(results_file, "%2.2f Meg bits per seconds\n", 8*(i*numbytes/et)/1000000);
printf("Go Again?\n");
scanf("%d", &go_again);
}
fclose(data_file);
fclose(results_file);
Another useful test might be to run all of the program except the 'send' line to see how much time the other parts take (again, probably not much, but worth checking)
Thanks Robin2,
If you're convinced I'm sending only a byte, then I'll take another look at the code. But I'm sure I'm sending lines of 20-30 bytes or whatever is typical of text documents.