commit 609fc9f9d97bc972b86dd4fe6ab74074d960b81f from: Omar Polo date: Fri Jan 22 17:18:55 2021 UTC use a c program to fill the file it's several order of magnitude faster than the equivalent shell script commit - 99f95f7762f61a020ab049ed24c9c9102e2c3250 commit + 609fc9f9d97bc972b86dd4fe6ab74074d960b81f blob - ab5dd84e2405008d509a713cd04c70b415ba22c4 blob + 6fc98a225571d76cf14bc3befa67fec023c0f603 --- .gitignore +++ .gitignore @@ -16,3 +16,6 @@ configure.local regress/testdata regress/*.pem regress/reg.conf +regress/fill-file +regress/iri_test +regress/*.o blob - 67948a4f872e0c745d6eefcc4447fe9b18837035 blob + 863e5e4234144c39370f21019f74206d3f35e190 --- regress/Makefile +++ regress/Makefile @@ -8,6 +8,9 @@ all: iri_test runtime iri_test: iri_test.o ../iri.o ../utf8.o ${CC} iri_test.o ../iri.o ../utf8.o -o iri_test ${LDFLAGS} +fill-file: fill-file.o + ${CC} fill-file.o -o fill-file + key.pem: cert.pem # XXX: key size is NOT GOOD. This is only for testing. Smaller keys @@ -24,9 +27,9 @@ clean: rm -f *.o iri_test cert.pem key.pem rm -rf testdata -testdata: +testdata: fill-file mkdir testdata - ./genbigfile testdata/bigfile + ./fill-file testdata/bigfile ./sha testdata/bigfile testdata/bigfile.sha printf "# hello world\n" > testdata/index.gmi ./sha testdata/index.gmi testdata/index.gmi.sha blob - /dev/null blob + 0cf4384d40186bb8ea02888d301caaf99521dc50 (mode 644) --- /dev/null +++ regress/fill-file.c @@ -0,0 +1,29 @@ +#include + +/* I need a big file made up of ascii characters. dd if=/dev/zero is + * thus not an option, truncate is not portable. This is some order + * of magnitude faster than the equivalent sh script */ + +int +main(int argc, char **argv) +{ + FILE *out; + int i, j; + + if (argc != 2) { + fprintf(stderr, "USAGE: %s \n", *argv); + return 1; + } + + if ((out = fopen(argv[1], "w")) == NULL) { + fprintf(stderr, "cannot open file: %s\n", argv[1]); + return 1; + } + + for (i = 0; i < 1024; ++i) + for (j = 0; j < 1024; ++j) + fprintf(out, "a\n"); + + fclose(out); + return 0; +}