Permalink
Browse files

start tidying up the error handling and add a runner script to graph

  • Loading branch information...
1 parent 1618c9e commit bf235a1e6a7be72da6f01afab1601236ccfc6db5 @avsm committed Oct 31, 2011
Showing with 26 additions and 14 deletions.
  1. +12 −14 pipe_lat.c
  2. +14 −0 run.sh
View
@@ -33,6 +33,7 @@
#include <sys/socket.h>
#include <sys/time.h>
#include <stdint.h>
+#include <err.h>
int main(int argc, char *argv[])
@@ -55,7 +56,7 @@ int main(int argc, char *argv[])
buf = malloc(size);
if (buf == NULL) {
- perror("malloc");
+ err(1, "malloc");
return 1;
}
@@ -73,31 +74,28 @@ int main(int argc, char *argv[])
}
if (!fork()) { /* child */
+ int r;
for (i = 0; i < count; i++) {
-
- if (read(ifds[0], buf, size) != size) {
- perror("read");
- return 1;
- }
-
- if (write(ofds[1], buf, size) != size) {
- perror("write");
- return 1;
- }
+ 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);
}
} else { /* parent */
-
gettimeofday(&start, NULL);
for (i = 0; i < count; i++) {
if (write(ifds[1], buf, size) != size) {
- perror("write");
+ perror("child write");
return 1;
}
if (read(ofds[0], buf, size) != size) {
- perror("read");
+ perror("child read");
return 1;
}
View
14 run.sh
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+
+SIZES="1 2 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536"
+NUMS="50000"
+TEST="pipe_lat unix_lat"
+
+for test in ${TEST}; do
+ for size in ${SIZES}; do
+ for num in ${NUMS}; do
+ echo ${test}: ${size} x ${num}
+ ./${test} ${size} ${num}
+ done
+ done
+done

0 comments on commit bf235a1

Please sign in to comment.