aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Seebach <peter.seebach@windriver.com>2011-02-01 13:07:03 -0600
committerPeter Seebach <peter.seebach@windriver.com>2011-02-01 13:07:03 -0600
commita4cf5f2f5bac9aeb1d9aac73140411b7eb69ee00 (patch)
treef56481e95749241afa9604a3540cbe0cede84170
parentd1d46ce88db792883ce9b1be00e2b5adeaf225bd (diff)
downloadpseudo-a4cf5f2f5bac9aeb1d9aac73140411b7eb69ee00.tar.gz
pseudo-a4cf5f2f5bac9aeb1d9aac73140411b7eb69ee00.tar.bz2
pseudo-a4cf5f2f5bac9aeb1d9aac73140411b7eb69ee00.zip
Add performance test (rough draft).
-rw-r--r--doc/perftest8
-rw-r--r--makedata.c32
-rwxr-xr-xperftest44
3 files changed, 84 insertions, 0 deletions
diff --git a/doc/perftest b/doc/perftest
new file mode 100644
index 0000000..b9169ae
--- /dev/null
+++ b/doc/perftest
@@ -0,0 +1,8 @@
+There's a new "perftest" program. I recommend you run it with a ramdisk. So,
+if you've mounted a ramdisk on /tmp/ram:
+ ./perftest /tmp/ram
+
+This is a pretty unscientific test, but is designed to exercise some
+reasonably common use cases and give ballpark figures as to the effect
+of changes to the database indexes, etc.
+
diff --git a/makedata.c b/makedata.c
new file mode 100644
index 0000000..a3f9a86
--- /dev/null
+++ b/makedata.c
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+int
+main(void) {
+ int i, j, k, l;
+ /* templateish form used so it's obvious that it's long enough */
+ char name[] = "dir_%d/dir_%d/%d%d.txt";
+ for (i = 0; i < 10; ++i) {
+ snprintf(name, sizeof(name), "dir_%d", i);
+ mkdir(name);
+ for (j = 0; j < 40; ++j) {
+ snprintf(name, sizeof(name), "dir_%d/dir_%d", i, j);
+ mkdir(name);
+ for (k = 0; k < 10; ++k) {
+ for (l = 0; l < 10; ++l) {
+ FILE *fp;
+ snprintf(name, sizeof(name),
+ "dir_%d/dir_%d/%d%d.txt",
+ i, j, k, l);
+ fp = fopen(name, "w");
+ if (fp) {
+ fprintf(fp, "dummy file.\n");
+ fclose(fp);
+ }
+ }
+ }
+ }
+ }
+ return 0;
+}
diff --git a/perftest b/perftest
new file mode 100755
index 0000000..55cb0cb
--- /dev/null
+++ b/perftest
@@ -0,0 +1,44 @@
+#!/bin/sh
+# do a quick performance test of pseudo
+die() {
+ printf "%s\n" "$*" >&2
+ exit 1
+}
+
+doit() (
+ cd $dir
+ printf "%s\n" "Making test data..."
+ time ./makedata
+ printf "%s\n" "Timing tar command."
+ time sh -c 'tar cf - dir_[0-9] | tar -C new -xf -'
+ printf "%s\n" "Timing find command."
+ time find new -perm 0100 -exec true {} +
+ printf "%s\n" "Timing rm."
+ time rm -rf dir_[0-9] new
+)
+
+[ -x bin/pseudo ] || die "You need a bin/pseudo to test."
+case $# in
+0) dir="perftest.d";;
+1) [ -d "$1" ] || die "Specify an existing directory to test in."
+ dir="$1/perftest.d"
+ ;;
+*) die "Usage: perftest [directory]"
+ ;;
+esac
+
+case `id -u` in
+0) printf "%s\n" "Running test."
+ doit
+ printf "%s\n" "Done."
+ ;;
+*) [ -d $dir ] && die "$dir directory already exists, delete it if you're done."
+ mkdir $dir
+ mkdir $dir/new
+ cc -o $dir/makedata makedata.c
+ printf "%s\n" "Running performance test (total time at end)"
+ time bin/pseudo ./perftest $1
+ rm -rf $dir
+ rm -f makedata
+ ;;
+esac