mirror of https://github.com/omar-polo/gmid.git
use a c program to fill the file
it's several order of magnitude faster than the equivalent shell script
This commit is contained in:
parent
99f95f7762
commit
609fc9f9d9
|
@ -16,3 +16,6 @@ configure.local
|
||||||
regress/testdata
|
regress/testdata
|
||||||
regress/*.pem
|
regress/*.pem
|
||||||
regress/reg.conf
|
regress/reg.conf
|
||||||
|
regress/fill-file
|
||||||
|
regress/iri_test
|
||||||
|
regress/*.o
|
||||||
|
|
|
@ -8,6 +8,9 @@ all: iri_test runtime
|
||||||
iri_test: iri_test.o ../iri.o ../utf8.o
|
iri_test: iri_test.o ../iri.o ../utf8.o
|
||||||
${CC} iri_test.o ../iri.o ../utf8.o -o iri_test ${LDFLAGS}
|
${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
|
key.pem: cert.pem
|
||||||
|
|
||||||
# XXX: key size is NOT GOOD. This is only for testing. Smaller keys
|
# 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 -f *.o iri_test cert.pem key.pem
|
||||||
rm -rf testdata
|
rm -rf testdata
|
||||||
|
|
||||||
testdata:
|
testdata: fill-file
|
||||||
mkdir testdata
|
mkdir testdata
|
||||||
./genbigfile testdata/bigfile
|
./fill-file testdata/bigfile
|
||||||
./sha testdata/bigfile testdata/bigfile.sha
|
./sha testdata/bigfile testdata/bigfile.sha
|
||||||
printf "# hello world\n" > testdata/index.gmi
|
printf "# hello world\n" > testdata/index.gmi
|
||||||
./sha testdata/index.gmi testdata/index.gmi.sha
|
./sha testdata/index.gmi testdata/index.gmi.sha
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* 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 <file>\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;
|
||||||
|
}
|
Loading…
Reference in New Issue