projects
/
bluesky.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Create a simple Python script for sending pipelined GET requests to S3.
[bluesky.git]
/
microbench
/
readbench.c
diff --git
a/microbench/readbench.c
b/microbench/readbench.c
index
88eb888
..
5a397e3
100644
(file)
--- a/
microbench/readbench.c
+++ b/
microbench/readbench.c
@@
-1,14
+1,17
@@
+#include <errno.h>
+#include <inttypes.h>
+#include <pthread.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <unistd.h>
-#include <errno.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include <time.h>
#include <time.h>
-#include <
pthrea
d.h>
+#include <
unist
d.h>
struct thread_state {
pthread_t thread;
struct thread_state {
pthread_t thread;
+ const char *filename;
int thread_num;
long long timestamp;
};
int thread_num;
long long timestamp;
};
@@
-54,21
+57,23
@@
void *benchmark_thread(void *arg)
{
struct thread_state *ts = (struct thread_state *)arg;
{
struct thread_state *ts = (struct thread_state *)arg;
- char namebuf[64];
- sprintf(namebuf, "file-%d", ts->thread_num);
- printf("Opening %s\n", namebuf);
+ printf("Opening %s\n", ts->filename);
int64_t start, end;
start = now_hires();
int64_t start, end;
start = now_hires();
- FILE *f = fopen(namebuf, "rb");
+
+ //struct stat stat_buf;
+ //stat(namebuf, &stat_buf);
+
+ FILE *f = fopen(ts->filename, "rb");
if (f == NULL) {
perror("fopen");
return NULL;
}
if (f == NULL) {
perror("fopen");
return NULL;
}
- char buf[
409
6];
- fread(buf, 1, sizeof(buf), f);
+ char buf[
6553
6];
+ while (fread(buf, 1, sizeof(buf), f) > 0) { }
end = now_hires();
printf("Thread %d: Time = %"PRIi64"\n", ts->thread_num, end - start);
end = now_hires();
printf("Thread %d: Time = %"PRIi64"\n", ts->thread_num, end - start);
@@
-78,10
+83,11
@@
void *benchmark_thread(void *arg)
return NULL;
}
return NULL;
}
-void launch_thread(int i)
+void launch_thread(int i
, const char *filename
)
{
threads[i].thread_num = i;
{
threads[i].thread_num = i;
- printf("Launching thread %d...\n", i);
+ threads[i].filename = filename;
+ printf("Launching thread %d [%s]...\n", i, filename);
if (pthread_create(&threads[i].thread, NULL, benchmark_thread, &threads[i]) != 0) {
fprintf(stderr, "Error launching thread!\n");
exit(1);
if (pthread_create(&threads[i].thread, NULL, benchmark_thread, &threads[i]) != 0) {
fprintf(stderr, "Error launching thread!\n");
exit(1);
@@
-96,11
+102,15
@@
void wait_thread(int n)
int main(int argc, char *argv[])
{
int main(int argc, char *argv[])
{
- for (int i = 0; i < 8; i++) {
- launch_thread(i);
+ int threads = argc - 1;
+
+ printf("Testing with %d threads\n", threads);
+
+ for (int i = 0; i < threads; i++) {
+ launch_thread(i, argv[i + 1]);
}
}
- for (int i = 0; i <
8
; i++) {
+ for (int i = 0; i <
threads
; i++) {
wait_thread(i);
}
wait_thread(i);
}