Skip to content

Commit

Permalink
Fix latency calc on 32bit systems
Browse files Browse the repository at this point in the history
Closes #23
  • Loading branch information
rigtorp committed Sep 25, 2023
1 parent b98ddf0 commit b281203
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.idea/
.idea/
.cache/
build/
6 changes: 3 additions & 3 deletions src/pipe_lat.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ int main(int argc, char *argv[]) {
return 1;
}

delta = ((stop.tv_sec - start.tv_sec) * 1000000000 +
delta = ((stop.tv_sec - start.tv_sec) * 1000000000LL +
(stop.tv_nsec - start.tv_nsec));

#else
Expand All @@ -136,8 +136,8 @@ int main(int argc, char *argv[]) {
return 1;
}

delta = (stop.tv_sec - start.tv_sec) * 1000000000 +
(stop.tv_usec - start.tv_usec) * 1000;
delta = (stop.tv_sec - start.tv_sec) * 1000000000LL +
(stop.tv_usec - start.tv_usec) * 1000LL;

#endif

Expand Down
6 changes: 3 additions & 3 deletions src/tcp_lat.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ int main(int argc, char *argv[]) {
return 1;
}

delta = ((stop.tv_sec - start.tv_sec) * 1000000000 +
delta = ((stop.tv_sec - start.tv_sec) * 1000000000LL +
(stop.tv_nsec - start.tv_nsec));

#else
Expand All @@ -196,8 +196,8 @@ int main(int argc, char *argv[]) {
return 1;
}

delta = (stop.tv_sec - start.tv_sec) * 1000000000 +
(stop.tv_usec - start.tv_usec) * 1000;
delta = (stop.tv_sec - start.tv_sec) * 1000000000LL +
(stop.tv_usec - start.tv_usec) * 1000LL;

#endif

Expand Down
4 changes: 2 additions & 2 deletions src/tcp_remote_lat.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ int main(int argc, char *argv[]) {

gettimeofday(&stop, NULL);

delta = (stop.tv_sec - start.tv_sec) * 1000000000 +
(stop.tv_usec - start.tv_usec) * 1000;
delta = (stop.tv_sec - start.tv_sec) * 1000000000LL +
(stop.tv_usec - start.tv_usec) * 1000LL;

printf("average latency: %" PRId64 " ns\n", delta / (count * 2));

Expand Down
6 changes: 3 additions & 3 deletions src/udp_lat.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ int main(int argc, char *argv[]) {
return 1;
}

delta = ((stop.tv_sec - start.tv_sec) * 1000000000 +
delta = ((stop.tv_sec - start.tv_sec) * 1000000000LL +
(stop.tv_nsec - start.tv_nsec));

#else
Expand All @@ -195,8 +195,8 @@ int main(int argc, char *argv[]) {
return 1;
}

delta = (stop.tv_sec - start.tv_sec) * 1000000000 +
(stop.tv_usec - start.tv_usec) * 1000;
delta = (stop.tv_sec - start.tv_sec) * 1000000000LL +
(stop.tv_usec - start.tv_usec) * 1000LL;

#endif

Expand Down
6 changes: 3 additions & 3 deletions src/unix_lat.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ int main(int argc, char *argv[]) {
return 1;
}

delta = ((stop.tv_sec - start.tv_sec) * 1000000000 +
delta = ((stop.tv_sec - start.tv_sec) * 1000000000LL +
(stop.tv_nsec - start.tv_nsec));

#else
Expand All @@ -129,8 +129,8 @@ int main(int argc, char *argv[]) {
return 1;
}

delta = (stop.tv_sec - start.tv_sec) * 1000000000 +
(stop.tv_usec - start.tv_usec) * 1000;
delta = (stop.tv_sec - start.tv_sec) * 1000000000LL +
(stop.tv_usec - start.tv_usec) * 1000LL;

#endif

Expand Down

0 comments on commit b281203

Please sign in to comment.