From: alex Date: Sat, 5 Mar 2022 18:57:19 +0000 (-0800) Subject: ... X-Git-Url: http://git.infiniteadaptability.org/?a=commitdiff_plain;h=9ac3f19b796497d62f689dd6ea586bc2cbd37901;p=seeder ... --- diff --git a/.gitignore b/.gitignore index 81b5d69..109ba99 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ seederd # test files/objects .test/ + +# bench files/objects +.bench/ diff --git a/Makefile.am b/Makefile.am index 65f17a3..cbf7be5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 index 0000000..ede76cc --- /dev/null +++ b/bench/Makefile.am @@ -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 index 0000000..b964415 --- /dev/null +++ b/bench/add.bench.c @@ -0,0 +1,10 @@ +#include + +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 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 index 0000000..c15018e --- /dev/null +++ b/bench/bench_utils.c @@ -0,0 +1,24 @@ +#include + +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 index 0000000..ef7d189 --- /dev/null +++ b/bench/bench_utils.h @@ -0,0 +1,15 @@ +#ifndef __BENCH_UTILS_H_ +#define __BENCH_UTILS_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +void create_tmp_file(char*,uint64_t); + +#endif diff --git a/configure.ac b/configure.ac index 096f106..c58bce1 100644 --- a/configure.ac +++ b/configure.ac @@ -74,5 +74,6 @@ AC_FUNC_MALLOC AC_CHECK_FUNCS([atexit]) AC_CONFIG_FILES([Makefile + bench/Makefile test/unit/Makefile]) AC_OUTPUT