Skip to content

Commit

Permalink
send: Make byteCount unsigned long
Browse files Browse the repository at this point in the history
Currently, negative benchmark values are shown:

    @ira$ send okeanos 34141
    start : 1647613816.868339
    close : 1647613826.868524
    done  : 1647613826.874427
    -1209148824 bytes in 10.006088 seconds
    -120841314.207910 bytes / seconds
    -966730513.663282 bits  / seconds
    -966730.513663 kBit/s  / seconds
    -966.730514 MBit/s  / seconds

With 10 Gbit/s, in 10 s seconds theoretically up to 12.5 GB could be
transferred. But a 32-bit (signed) integer can at maximum store the
number (2147483648 - 1), and the unsigned integer around 4.3 million,
still too small.

Therefore, use unsigned long to be able to store the number bytes
without overflow for the foreseeable future. Now we have:

    @ira$ ./send okeanos 34141
    start : 1647626064.313421
    close : 1647626074.313503
    done  : 1647626074.317791
    10534190976 bytes in 10.004370 seconds
    1052958954.536867 bytes / seconds
    8423671636.294939 bits  / seconds
    8423671.636295 kBit/s  / seconds
    8423.671636 MBit/s  / seconds

Resolves: mariux64/mariux64-issues#23
  • Loading branch information
pmenzel committed Mar 18, 2022
1 parent a842a94 commit 08e1a93
Showing 2 changed files with 2 additions and 2 deletions.
Binary file modified send/send
Binary file not shown.
4 changes: 2 additions & 2 deletions send/send.c
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ int main(int argc,char *argv[]) {
int s;
int i;
int status;
int byteCount;
unsigned long byteCount;
double bps;
struct timeval startTime;
struct timeval endTime;
@@ -131,7 +131,7 @@ int main(int argc,char *argv[]) {
{ double sec;
sec = endTime.tv_sec - startTime.tv_sec +
(double)(endTime.tv_usec - startTime.tv_usec)/1000000;
printf ("%d bytes in %f seconds\n",byteCount,sec);
printf ("%lu bytes in %f seconds\n",byteCount,sec);
printf ("%f bytes / seconds\n",(double)byteCount/sec);
printf ("%f bits / seconds\n",(double)byteCount*8/sec);
printf ("%f kBit/s / seconds\n",(double)byteCount*8/1000/sec);

0 comments on commit 08e1a93

Please sign in to comment.