summaryrefslogtreecommitdiff
path: root/jstests/perf
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2011-12-01 11:27:43 -0500
committerEric Milkie <milkie@10gen.com>2011-12-01 11:27:43 -0500
commit72e08f48437c1e8083901f0bf59c28753a56b011 (patch)
tree0b8bbf5512cde96e2b447372cf8507dd7f70ab80 /jstests/perf
parent6619cce4ea948f5890718f1c2b5629156db8c579 (diff)
downloadmongo-72e08f48437c1e8083901f0bf59c28753a56b011.tar.gz
the compact perf test would live better in perf/
Diffstat (limited to 'jstests/perf')
-rwxr-xr-xjstests/perf/compact_speed_test.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/jstests/perf/compact_speed_test.js b/jstests/perf/compact_speed_test.js
new file mode 100755
index 00000000000..61733f104c2
--- /dev/null
+++ b/jstests/perf/compact_speed_test.js
@@ -0,0 +1,57 @@
+if (1) {
+
+ t = db.compactspeedtest;
+ t.drop();
+
+ var obj = { x: 1, y: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", z: [1, 2] };
+
+ var start = new Date();
+ function timed() {
+ db.getLastError();
+ var dt = (new Date()) - start;
+ //print("time: " + dt);
+ start = new Date();
+ return dt;
+ }
+
+ //print("adding data");
+ var N = 100000;
+ if (db.adminCommand("buildInfo").debug)
+ N = 10000;
+ for (var i = 0; i < N; i++) {
+ obj.x = i;
+ obj.z[1] = i;
+ t.insert(obj);
+ }
+ var a = timed();
+
+ //print("index");
+ t.ensureIndex({ x: 1 });
+ //print("index");
+ t.ensureIndex({ y: 1 });
+ //print("index");
+ t.ensureIndex({ z: 1 });
+
+ a += timed();
+
+ //print("count:" + t.count());
+
+ timed();
+
+ {
+ //print("compact");
+ var res = db.runCommand({ compact: 'compactspeedtest', dev: true });
+ b = timed();
+ //printjson(res);
+ assert(res.ok);
+
+ //print("validate");
+ var v = t.validate(true);
+
+ assert(v.ok);
+ assert(t.getIndexes().length == 4);
+ print("inserting records and adding indexes took " + a);
+ print("compact took " + b);
+ assert(b < a, "compact was slower than it should be");
+ }
+}