couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r884716 - in /couchdb/trunk: bench/ configure.ac test/Makefile.am test/bench/ test/bench/Makefile.am test/bench/bench_lib.js test/bench/bench_marks.js test/bench/benches.js test/bench/run.tpl test/bench/runner.sh
Date Thu, 26 Nov 2009 22:45:10 GMT
Author: davisp
Date: Thu Nov 26 22:45:09 2009
New Revision: 884716

URL: http://svn.apache.org/viewvc?rev=884716&view=rev
Log:
Updated the benchmarks to use the new cURL adapter.

Moved the bench directory into the tests directory.
Refactored the benchmarks to reuse more of the code from the JavaScript CLI test runner.


Added:
    couchdb/trunk/test/bench/   (props changed)
      - copied from r884679, couchdb/trunk/bench/
    couchdb/trunk/test/bench/bench_marks.js
      - copied, changed from r884679, couchdb/trunk/bench/benches.js
    couchdb/trunk/test/bench/run.tpl
      - copied, changed from r884679, couchdb/trunk/bench/runner.sh
Removed:
    couchdb/trunk/bench/
    couchdb/trunk/test/bench/bench_lib.js
    couchdb/trunk/test/bench/benches.js
    couchdb/trunk/test/bench/runner.sh
Modified:
    couchdb/trunk/configure.ac
    couchdb/trunk/test/Makefile.am
    couchdb/trunk/test/bench/Makefile.am

Modified: couchdb/trunk/configure.ac
URL: http://svn.apache.org/viewvc/couchdb/trunk/configure.ac?rev=884716&r1=884715&r2=884716&view=diff
==============================================================================
--- couchdb/trunk/configure.ac (original)
+++ couchdb/trunk/configure.ac Thu Nov 26 22:45:09 2009
@@ -403,6 +403,7 @@
 AC_CONFIG_FILES([src/ibrowse/Makefile])
 AC_CONFIG_FILES([src/mochiweb/Makefile])
 AC_CONFIG_FILES([test/Makefile])
+AC_CONFIG_FILES([test/bench/Makefile])
 AC_CONFIG_FILES([test/etap/Makefile])
 AC_CONFIG_FILES([test/etap/test_util.erl])
 AC_CONFIG_FILES([test/javascript/Makefile])

Modified: couchdb/trunk/test/Makefile.am
URL: http://svn.apache.org/viewvc/couchdb/trunk/test/Makefile.am?rev=884716&r1=884715&r2=884716&view=diff
==============================================================================
--- couchdb/trunk/test/Makefile.am (original)
+++ couchdb/trunk/test/Makefile.am Thu Nov 26 22:45:09 2009
@@ -10,5 +10,5 @@
 ## License for the specific language governing permissions and limitations under
 ## the License.
 
-SUBDIRS = etap javascript view_server
+SUBDIRS = bench etap javascript view_server
 

Propchange: couchdb/trunk/test/bench/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Nov 26 22:45:09 2009
@@ -0,0 +1,3 @@
+Makefile
+Makefile.in
+run

Modified: couchdb/trunk/test/bench/Makefile.am
URL: http://svn.apache.org/viewvc/couchdb/trunk/test/bench/Makefile.am?rev=884716&r1=884679&r2=884716&view=diff
==============================================================================
--- couchdb/trunk/test/bench/Makefile.am (original)
+++ couchdb/trunk/test/bench/Makefile.am Thu Nov 26 22:45:09 2009
@@ -10,7 +10,13 @@
 ## License for the specific language governing permissions and limitations under
 ## the License.
 
-EXTRA_DIST = \
-    bench_lib.js \
-    runner.sh \
-    benches.js
+EXTRA_DIST = benchbulk.sh benches.js
+
+noinst_SCRIPTS = run
+CLEANFILES = run
+
+run: run.tpl
+	sed -e "s|%abs_top_srcdir%|$(abs_top_srcdir)|" \
+		-e "s|%abs_top_builddir%|$(abs_top_builddir)|" \
+	< $< > $@
+	chmod +x $@

Copied: couchdb/trunk/test/bench/bench_marks.js (from r884679, couchdb/trunk/bench/benches.js)
URL: http://svn.apache.org/viewvc/couchdb/trunk/test/bench/bench_marks.js?p2=couchdb/trunk/test/bench/bench_marks.js&p1=couchdb/trunk/bench/benches.js&r1=884679&r2=884716&rev=884716&view=diff
==============================================================================
--- couchdb/trunk/bench/benches.js (original)
+++ couchdb/trunk/test/bench/bench_marks.js Thu Nov 26 22:45:09 2009
@@ -10,22 +10,28 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
+var NUM_DOCS = 2000;
+var NUM_BATCHES = 20;
 
-var allBenches = {};
+var init = function() {
+  var db = new CouchDB("bench_mark_db", {"X-Couch-Full-Commit": "false"});
+  db.deleteDb();
+  db.createDb();
+  return db;
+};
 
-allBenches.single_doc_insert = function(db, acc) {
-  db.save({"foo":"bar"});
-  acc.docs++;
-  return acc;
+var timeit = function(func) {
+  var startTime = (new Date()).getTime();
+  func();
+  return ((new Date()).getTime() - startTime) / 1000;
 };
 
-allBenches.batch_ok_doc_insert = function(db, acc) {
-  db.save({"foo":"bar"}, {"batch":"ok"});
-  acc.docs++;
-  return acc;  
+var report = function(name, rate) {
+  rate = Math.round(parseFloat(rate) * 100) / 100;
+  console.log("" + name + ": " + rate + " docs/second");
 };
 
-function makeDocs(n) {
+var makeDocs = function(n) {
   docs = [];
   for (var i=0; i < n; i++) {
     docs.push({"foo":"bar"});
@@ -33,30 +39,65 @@
   return docs;
 };
 
-allBenches.bulk_doc_100 = function(db, acc) {
-  var docs = makeDocs(100);
-  db.bulkSave(docs);
-  acc.docs += 100;
-  return acc;  
-};
-
-allBenches.bulk_doc_1000 = function(db, acc) {
-  var docs = makeDocs(1000);
-  db.bulkSave(docs);
-  acc.docs += 1000;
-  return acc;  
-};
-
-allBenches.bulk_doc_5000 = function(db, acc) {
-  var docs = makeDocs(5000);
-  db.bulkSave(docs);
-  acc.docs += 5000;
-  return acc;  
-};
-
-allBenches.bulk_doc_10000 = function(db, acc) {
-  var docs = makeDocs(10000);
-  db.bulkSave(docs);
-  acc.docs += 10000;
-  return acc;  
-};
\ No newline at end of file
+var couchTests = {};
+
+couchTests.single_doc_insert = function() {
+  var db = init();
+  var len = timeit(function() {
+    for(var i = 0; i < NUM_DOCS; i++) {
+      db.save({"foo": "bar"});
+    }
+  });
+  report("Single doc inserts", NUM_DOCS/len);
+};
+
+couchTests.batch_ok_doc_insert = function() {
+  var db = init();
+  var len = timeit(function() {
+    for(var i = 0; i < NUM_DOCS; i++) {
+      db.save({"foo":"bar"}, {"batch":"ok"});
+    }
+  });
+  report("Single doc inserts with batch=ok", NUM_DOCS/len);
+};
+
+couchTests.bulk_doc_100 = function() {
+  var db = init();
+  var len = timeit(function() {
+    for(var i = 0; i < NUM_BATCHES; i++) {
+      db.bulkSave(makeDocs(100));
+    }
+  });
+  report("Bulk docs - 100", (NUM_BATCHES*100)/len);
+};
+      
+couchTests.bulk_doc_1000 = function() {
+  var db = init();
+  var len = timeit(function() {
+    for(var i = 0; i < NUM_BATCHES; i++) {
+      db.bulkSave(makeDocs(1000));
+    }
+  });
+  report("Bulk docs - 1000", (NUM_BATCHES*1000)/len);
+};
+
+
+couchTests.bulk_doc_5000 = function() {
+  var db = init();
+  var len = timeit(function() {
+    for(var i = 0; i < NUM_BATCHES; i++) {
+      db.bulkSave(makeDocs(5000));
+    }
+  });
+  report("Bulk docs - 5000", (NUM_BATCHES*5000)/len);
+};
+
+couchTests.bulk_doc_10000 = function() {
+  var db = init();
+  var len = timeit(function() {
+    for(var i = 0; i < NUM_BATCHES; i++) {
+      db.bulkSave(makeDocs(10000));
+    }
+  });
+  report("Bulk docs - 10000", (NUM_BATCHES*10000)/len);
+};

Copied: couchdb/trunk/test/bench/run.tpl (from r884679, couchdb/trunk/bench/runner.sh)
URL: http://svn.apache.org/viewvc/couchdb/trunk/test/bench/run.tpl?p2=couchdb/trunk/test/bench/run.tpl&p1=couchdb/trunk/bench/runner.sh&r1=884679&r2=884716&rev=884716&view=diff
==============================================================================
--- couchdb/trunk/bench/runner.sh (original)
+++ couchdb/trunk/test/bench/run.tpl Thu Nov 26 22:45:09 2009
@@ -12,7 +12,17 @@
 # License for the specific language governing permissions and limitations under
 # the License.
 
-cat ../share/www/script/couch.js \
-    benches.js \
-    bench_lib.js \
-    | ../src/couchdb/couchjs -
+SRC_DIR=%abs_top_srcdir%
+SCRIPT_DIR=$SRC_DIR/share/www/script
+JS_TEST_DIR=$SRC_DIR/test/javascript
+JS_BENCH_DIR=$SRC_DIR/test/bench
+
+COUCHJS=%abs_top_builddir%/src/couchdb/priv/couchjs
+
+cat $SCRIPT_DIR/json2.js \
+    $SCRIPT_DIR/couch.js \
+    $JS_TEST_DIR/couch_http.js \
+    $JS_BENCH_DIR/bench_marks.js \
+    $JS_TEST_DIR/cli_runner.js \
+    | $COUCHJS -
+



Mime
View raw message