Useful for testing. Note that we *don't* see the random number generator,
so every time you generate the bytes, you get the same sequence.
This is also vastly faster than /dev/urandom, since it doesn't try to be
cryptographically secure. It generates about 200 megs/sec on my computer,
which is much faster than a disk and thus useful for testing the speed of
hashsplit.
hjoin
hashsplit
hashjoin
+datagen
*.o
*~
tags[12]
default: all
-all: hashsplit hashjoin
+all: hashsplit hashjoin datagen
hashsplit: hashsplit.o
+datagen: datagen.o
+
hashjoin: hashjoin.sh
test: hashsplit hashjoin
gcc -c -o $@ $^ $(CPPFLAGS) $(CFLAGS)
clean:
- rm -f *.o *~ hashsplit hashjoin hsplit hjoin \
+ rm -f *.o *~ hashsplit hashjoin hsplit hjoin datagen \
out[12] tags[12] .*~
--- /dev/null
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+int main(int argc, char **argv)
+{
+ if (argc != 2)
+ {
+ fprintf(stderr, "usage: %s <kbytes>\n", argv[0]);
+ return 1;
+ }
+
+ int kbytes = atoi(argv[1]);
+ uint32_t buf[1024/4];
+ int i;
+
+ for (; kbytes > 0; kbytes--)
+ {
+ for (i = 0; i < sizeof(buf)/sizeof(buf[0]); i++)
+ buf[i] = random();
+ write(1, buf, sizeof(buf));
+ if (!(kbytes%1024))
+ fprintf(stderr, ".");
+ }
+
+ return 0;
+}