forked from avsm/ipc-bench
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup of the various tests and more structured output for graphing
- Loading branch information
Showing
10 changed files
with
191 additions
and
422 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/* | ||
Measure latency of IPC using unix domain sockets | ||
Copyright (c) 2010 Erik Rigtorp <[email protected]> | ||
Copyright (c) 2011 Anil Madhavapeddy <[email protected]> | ||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
|
@@ -26,17 +26,16 @@ | |
OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
|
||
#include <unistd.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <sys/socket.h> | ||
#include <sys/time.h> | ||
#include <stdint.h> | ||
#include <inttypes.h> | ||
#include <err.h> | ||
#include "xutil.h" | ||
|
||
|
||
int main(int argc, char *argv[]) | ||
int | ||
main(int argc, char *argv[]) | ||
{ | ||
int ofds[2]; | ||
int ifds[2]; | ||
|
@@ -54,61 +53,32 @@ int main(int argc, char *argv[]) | |
size = atoi(argv[1]); | ||
count = atol(argv[2]); | ||
|
||
buf = malloc(size); | ||
if (buf == NULL) { | ||
err(1, "malloc"); | ||
return 1; | ||
} | ||
|
||
printf("message size: %i octets\n", size); | ||
printf("roundtrip count: %lli\n", count); | ||
buf = xmalloc(size); | ||
|
||
if (pipe(ofds) == -1) { | ||
perror("pipe"); | ||
return 1; | ||
} | ||
if (pipe(ofds) == -1) | ||
err(1, "pipe"); | ||
|
||
if (pipe(ifds) == -1) { | ||
perror("pipe"); | ||
return 1; | ||
} | ||
if (pipe(ifds) == -1) | ||
err(1, "pipe"); | ||
|
||
if (!fork()) { /* child */ | ||
int r; | ||
for (i = 0; i < count; i++) { | ||
r = read(ifds[0], buf, size); | ||
if (r != size) | ||
err(1, "child read ret=%d", r); | ||
|
||
r = write(ofds[1], buf, size); | ||
if (r != size) | ||
err(1, "child write ret=%d", r); | ||
xread(ifds[0], buf, size); | ||
xwrite(ofds[1], buf, size); | ||
} | ||
} else { /* parent */ | ||
gettimeofday(&start, NULL); | ||
|
||
for (i = 0; i < count; i++) { | ||
|
||
if (write(ifds[1], buf, size) != size) { | ||
perror("child write"); | ||
return 1; | ||
} | ||
|
||
if (read(ofds[0], buf, size) != size) { | ||
perror("child read"); | ||
return 1; | ||
} | ||
|
||
xwrite(ifds[1], buf, size); | ||
xread(ofds[0], buf, size); | ||
} | ||
|
||
gettimeofday(&stop, NULL); | ||
|
||
delta = ((stop.tv_sec - start.tv_sec) * (int64_t) 1000000 + | ||
stop.tv_usec - start.tv_usec); | ||
|
||
printf("average latency: %lli us\n", delta / (count * 2)); | ||
|
||
printf("pipe_lat %d %" PRId64 " %" PRId64 "\n", size, count, delta / (count * 2)); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/* | ||
Measure throughput of IPC using pipes | ||
Copyright (c) 2010 Erik Rigtorp <[email protected]> | ||
Copyright (c) 2011 Anil Madhavapeddy <[email protected]> | ||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
|
@@ -31,10 +31,12 @@ | |
#include <stdlib.h> | ||
#include <sys/socket.h> | ||
#include <sys/time.h> | ||
#include <stdint.h> | ||
|
||
#include <inttypes.h> | ||
#include <err.h> | ||
#include "xutil.h" | ||
|
||
int main(int argc, char *argv[]) | ||
int | ||
main(int argc, char *argv[]) | ||
{ | ||
int fds[2]; | ||
|
||
|
@@ -51,48 +53,30 @@ int main(int argc, char *argv[]) | |
size = atoi(argv[1]); | ||
count = atol(argv[2]); | ||
|
||
buf = malloc(size); | ||
if (buf == NULL) { | ||
perror("malloc"); | ||
exit(1); | ||
} | ||
buf = xmalloc(size); | ||
|
||
printf("message size: %i octets\n", size); | ||
printf("message count: %lli\n", count); | ||
|
||
if (pipe(fds) == -1) { | ||
perror("pipe"); | ||
exit(1); | ||
} | ||
if (pipe(fds) == -1) | ||
err(1, "pipe"); | ||
|
||
if (!fork()) { | ||
/* child */ | ||
|
||
for (i = 0; i < count; i++) { | ||
if (read(fds[0], buf, size) != size) { | ||
perror("read"); | ||
exit(1); | ||
} | ||
} | ||
for (i = 0; i < count; i++) | ||
xread(fds[0], buf, size); | ||
} else { | ||
/* parent */ | ||
|
||
gettimeofday(&start, NULL); | ||
|
||
for (i = 0; i < count; i++) { | ||
if (write(fds[1], buf, size) != size) { | ||
perror("write"); | ||
exit(1); | ||
} | ||
} | ||
for (i = 0; i < count; i++) | ||
xwrite(fds[1], buf, size); | ||
|
||
gettimeofday(&stop, NULL); | ||
|
||
delta = ((stop.tv_sec - start.tv_sec) * (int64_t) 1e6 + | ||
stop.tv_usec - start.tv_usec); | ||
|
||
printf("average throughput: %lli msg/s\n", (count * (int64_t) 1e6) / delta); | ||
printf("average throughput: %lli Mb/s\n", (((count * (int64_t) 1e6) / delta) * size * 8) / (int64_t) 1e6); | ||
printf("pipe_thr %d %" PRId64 " %" PRId64 "\n", size, count, (((count * (int64_t) 1e6) / delta) * size * 8) / (int64_t) 1e6); | ||
} | ||
|
||
return 0; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
SIZES="1 2 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536" | ||
NUMS="50000" | ||
TEST="pipe_lat unix_lat" | ||
#SIZES="1 2 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536" | ||
#SIZES="1 8 32 64 256 1024 4096 8192 16384 32768 65536" | ||
SIZES="8 64 1024 8192 16384" | ||
NUMS="40000" | ||
TEST="pipe_lat unix_lat tcp_lat tcp_thr pipe_thr unix_thr" | ||
|
||
IF=eth0 | ||
EXTERNAL_IP=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}') | ||
|
||
OUT=results.csv | ||
rm -f ${OUT} | ||
|
||
for test in ${TEST}; do | ||
for size in ${SIZES}; do | ||
for num in ${NUMS}; do | ||
echo ${test}: ${size} x ${num} | ||
./${test} ${size} ${num} | ||
./${test} ${size} ${num} >> ${OUT} | ||
done | ||
done | ||
done |
Oops, something went wrong.