...
authoralex <[email protected]>
Sat, 5 Mar 2022 18:57:19 +0000 (10:57 -0800)
committeralex <[email protected]>
Sat, 5 Mar 2022 18:57:19 +0000 (10:57 -0800)
.gitignore
Makefile.am
bench/Makefile.am [new file with mode: 0644]
bench/add.bench.c [new file with mode: 0644]
bench/add_bench [new file with mode: 0755]
bench/bench_utils.c [new file with mode: 0644]
bench/bench_utils.h [new file with mode: 0644]
configure.ac

index 81b5d6907719fd9eb1bed84f80319cda070ea776..109ba994d6f35cff60bceffdfcb98404e108e25f 100644 (file)
@@ -32,3 +32,6 @@ seederd
 
 # test files/objects
 .test/
+
+# bench files/objects
+.bench/
index 65f17a33354a52d44c9417ec2de4aa93feff5fc8..cbf7be581642a046f24f04cf8b537209d39a674a 100644 (file)
@@ -93,4 +93,4 @@ seederd_SOURCES += \
        inc/usage.h \
        inc/watch.h
 
-SUBDIRS = . test/unit
+SUBDIRS = . test/unit bench
diff --git a/bench/Makefile.am b/bench/Makefile.am
new file mode 100644 (file)
index 0000000..ede76cc
--- /dev/null
@@ -0,0 +1,16 @@
+AM_CPPFLAGS = \
+       -DPREFIX=\".bench\" \
+       -Wall \
+       -Werror
+
+EXTRA_DIST = \
+       bench_utils.h
+
+bin_PROGRAMS = add_bench
+
+common_SOURCES = \
+       bench_utils.c
+
+add_bench_SOURCES = \
+       $(common_SOURCES) \
+       add.bench.c
diff --git a/bench/add.bench.c b/bench/add.bench.c
new file mode 100644 (file)
index 0000000..b964415
--- /dev/null
@@ -0,0 +1,10 @@
+#include<bench_utils.h>
+
+int main();
+
+int main() {
+       char template[] = PREFIX "/XXXXXX";
+       create_tmp_file(template,10000);
+
+       return EXIT_SUCCESS;
+}
diff --git a/bench/add_bench b/bench/add_bench
new file mode 100755 (executable)
index 0000000..63f2056
Binary files /dev/null and b/bench/add_bench differ
diff --git a/bench/bench_utils.c b/bench/bench_utils.c
new file mode 100644 (file)
index 0000000..c15018e
--- /dev/null
@@ -0,0 +1,24 @@
+#include<bench_utils.h>
+
+void create_tmp_file(char *template, size_t size) {
+       int urandom, fd;
+       char buf[65636];
+       ssize_t i;
+
+       urandom = open("/dev/urandom",O_RDONLY);
+       assert(urandom!=-1);
+
+       fd = mkstemp(template);
+       assert(fd!=-1);
+
+       while(size>0) {
+               i = read(urandom,buf,65636);
+               assert(i!=-1);
+
+               assert(i==write(fd,buf,i));
+               size -= i;
+       }
+
+       close(urandom);
+       close(fd);
+}
diff --git a/bench/bench_utils.h b/bench/bench_utils.h
new file mode 100644 (file)
index 0000000..ef7d189
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef __BENCH_UTILS_H_
+#define __BENCH_UTILS_H_
+
+#include<assert.h>
+#include<fcntl.h>
+#include<stdint.h>
+#include<stdio.h>
+#include<stdlib.h>
+#include<sys/types.h>
+#include<sys/stat.h>
+#include<unistd.h>
+
+void create_tmp_file(char*,uint64_t);
+
+#endif
index 096f106aee52e38535259f4137c3097b8817826c..c58bce154ee4a22c4192e7111655fb03a0b59311 100644 (file)
@@ -74,5 +74,6 @@ AC_FUNC_MALLOC
 AC_CHECK_FUNCS([atexit])
 
 AC_CONFIG_FILES([Makefile
+                bench/Makefile
                 test/unit/Makefile])
 AC_OUTPUT