summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/user/app/iostress/iostress.c44
1 files changed, 31 insertions, 13 deletions
diff --git a/src/user/app/iostress/iostress.c b/src/user/app/iostress/iostress.c
index 27e9d33..2f15471 100644
--- a/src/user/app/iostress/iostress.c
+++ b/src/user/app/iostress/iostress.c
@@ -1,25 +1,43 @@
-#include <stdio.h>
#include <camellia/syscalls.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
#include <x86intrin.h>
-#define NUM_RUNS 4
-#define NUM_CALLS 512
+int main(int argc, char **argv) {
+ long num_runs = 4;
+ long num_calls = 512;
+ long num_bytes = 1;
+ uint64_t *results;
+ char *inbuf;
+
+ if (argc > 1) num_runs = strtol(argv[1], NULL, 0);
+ if (argc > 2) num_calls = strtol(argv[2], NULL, 0);
+ if (argc > 3) num_bytes = strtol(argv[3], NULL, 0);
+ if (argc > 4 || num_runs == 0 || num_calls == 0) {
+ fprintf(stderr, "usage: %s [num_runs] [num_calls] [num_bytes]\n", argv[0]);
+ return 1;
+ }
-int main(void) {
- uint64_t time;
- uint64_t results[8];
+ results = malloc(sizeof(*results) * num_runs);
+ inbuf = malloc(num_bytes);
+ memset(inbuf, '.', num_bytes);
- for (int i = 0; i < NUM_RUNS; i++) {
- time = __rdtsc();
- for (int j = 0; j < NUM_CALLS; j++)
- _syscall_write(1, ".", 1, -1, 0);
- _syscall_write(1, "\n", 1, -1, 0);
+ for (long i = 0; i < num_runs; i++) {
+ uint64_t time = __rdtsc();
+ for (long j = 0; j < num_calls; j++)
+ _syscall_write(1, inbuf, num_bytes, -1, 0);
results[i] = __rdtsc() - time;
+ _syscall_write(1, "\n", 1, -1, 0);
}
- for (int i = 0; i < NUM_RUNS; i++) {
- printf("run %u: %u\n", i, results[i] / 3000);
+ uint64_t total = 0;
+ for (long i = 0; i < num_runs; i++) {
+ uint64_t scaled = results[i] / 3000;
+ total += scaled;
+ fprintf(stderr, "run %u: %u\n", i, scaled);
}
+ fprintf(stderr, "%u calls, %u bytes. avg %u\n", num_calls, num_bytes, total / num_runs);
return 0;
}