Add scripts for automatically testing reads at different settings.
[bluesky.git] / microbench / readbench.c
index 88eb888..84d6a82 100644 (file)
@@ -55,7 +55,7 @@ void *benchmark_thread(void *arg)
     struct thread_state *ts = (struct thread_state *)arg;
 
     char namebuf[64];
-    sprintf(namebuf, "file-%d", ts->thread_num);
+    sprintf(namebuf, "file-%d", ts->thread_num + 1);
     printf("Opening %s\n", namebuf);
 
     int64_t start, end;
@@ -96,11 +96,20 @@ void wait_thread(int n)
 
 int main(int argc, char *argv[])
 {
-    for (int i = 0; i < 8; i++) {
+    int threads = 8;
+
+    if (argc > 1)
+        threads = atoi(argv[1]);
+    if (threads > MAX_THREADS)
+        threads = MAX_THREADS;
+
+    printf("Testing with %d threads\n", threads);
+
+    for (int i = 0; i < threads; i++) {
         launch_thread(i);
     }
 
-    for (int i = 0; i < 8; i++) {
+    for (int i = 0; i < threads; i++) {
         wait_thread(i);
     }