commit e0f2a2ec14bd86f158061c82b76ccfa30b7455f0
parent e008618784c381cb217148b22a8f0a7b3577a298
Author: glenda <glenda@device>
Date: Mon, 24 Oct 2022 21:31:22 +0000
add src/bench
Diffstat:
3 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/src/bench/mkfile b/src/bench/mkfile
@@ -0,0 +1,5 @@
+</$objtype/mkfile
+BIN=.
+TARG=reader writer
+
+</sys/src/cmd/mkmany
diff --git a/src/bench/reader.c b/src/bench/reader.c
@@ -0,0 +1,13 @@
+#include <u.h>
+#include <libc.h>
+#define BSize (1024 * 1024 * 64)
+void
+main(void)
+{
+ long n;
+ char *buf = malloc(BSize);
+ while ((n = read(0, buf, BSize)) > 0) {
+ fprint(2, "reader: %ld/%d\n", n, BSize);
+ }
+ if (n < 0) sysfatal("%r");
+}
diff --git a/src/bench/writer.c b/src/bench/writer.c
@@ -0,0 +1,18 @@
+#include <u.h>
+#include <libc.h>
+#define BSize (1024 * 1024 * 64)
+void
+main(void)
+{
+ int i;
+ long n;
+ n = 1;
+ char *buf = malloc(BSize);
+ fprint(2, "writer begin\n");
+ for (i = 0; (i < 8) && (n > 0); i++) {
+ n = write(1, buf, BSize);
+ fprint(2, "writer: %ld/%d\n", n, BSize);
+ }
+ if (n < 0) sysfatal("%r");
+ fprint(2, "writer end, %d\n", i);
+}