diff options
author | Brad Anderson <brad@cloudant.com> | 2010-08-18 16:16:09 -0400 |
---|---|---|
committer | Adam Kocoloski <adam@cloudant.com> | 2010-08-18 17:19:37 -0400 |
commit | 6d18638d747374cb0e90e9bcbefbc71d959254fd (patch) | |
tree | 51ee2c2fd1020550e56febb03c740582af04dfce /test/bench | |
parent | 1fda1aa8f69d5870c5711b0068971c7d4594e6cc (diff) |
clear out root folder a bit, moving couch bits into apps/couch or rel/
Diffstat (limited to 'test/bench')
-rw-r--r-- | test/bench/bench_marks.js | 103 | ||||
-rwxr-xr-x | test/bench/benchbulk.sh | 69 | ||||
-rwxr-xr-x | test/bench/run.tpl | 28 |
3 files changed, 0 insertions, 200 deletions
diff --git a/test/bench/bench_marks.js b/test/bench/bench_marks.js deleted file mode 100644 index 4025adbb..00000000 --- a/test/bench/bench_marks.js +++ /dev/null @@ -1,103 +0,0 @@ -// Licensed under the Apache License, Version 2.0 (the "License"); you may not -// use this file except in compliance with the License. You may obtain a copy of -// the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -// License for the specific language governing permissions and limitations under -// the License. - -var NUM_DOCS = 2000; -var NUM_BATCHES = 20; - -var init = function() { - var db = new CouchDB("bench_mark_db", {"X-Couch-Full-Commit": "false"}); - db.deleteDb(); - db.createDb(); - return db; -}; - -var timeit = function(func) { - var startTime = (new Date()).getTime(); - func(); - return ((new Date()).getTime() - startTime) / 1000; -}; - -var report = function(name, rate) { - rate = Math.round(parseFloat(rate) * 100) / 100; - console.log("" + name + ": " + rate + " docs/second"); -}; - -var makeDocs = function(n) { - docs = []; - for (var i=0; i < n; i++) { - docs.push({"foo":"bar"}); - }; - return docs; -}; - -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); -}; diff --git a/test/bench/benchbulk.sh b/test/bench/benchbulk.sh deleted file mode 100755 index 22804c64..00000000 --- a/test/bench/benchbulk.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh -e -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -# - -# usage: time benchbulk.sh -# it takes about 30 seconds to run on my old MacBook with bulksize 1000 - -BULKSIZE=100 -DOCSIZE=10 -INSERTS=10 -ROUNDS=10 -DBURL="http://127.0.0.1:5984/benchbulk" -POSTURL="$DBURL/_bulk_docs" - -function make_bulk_docs() { - ROW=0 - SIZE=$(($1-1)) - START=$2 - BODYSIZE=$3 - - BODY=$(printf "%0${BODYSIZE}d") - - echo '{"docs":[' - while [ $ROW -lt $SIZE ]; do - printf '{"_id":"%020d", "body":"'$BODY'"},' $(($ROW + $START)) - let ROW=ROW+1 - done - printf '{"_id":"%020d", "body":"'$BODY'"}' $(($ROW + $START)) - echo ']}' -} - -echo "Making $INSERTS bulk inserts of $BULKSIZE docs each" - -echo "Attempt to delete db at $DBURL" -curl -X DELETE $DBURL -w\\n - -echo "Attempt to create db at $DBURL" -curl -X PUT $DBURL -w\\n - -echo "Running $ROUNDS rounds of $INSERTS concurrent inserts to $POSTURL" -RUN=0 -while [ $RUN -lt $ROUNDS ]; do - - POSTS=0 - while [ $POSTS -lt $INSERTS ]; do - STARTKEY=$[ POSTS * BULKSIZE + RUN * BULKSIZE * INSERTS ] - echo "startkey $STARTKEY bulksize $BULKSIZE" - DOCS=$(make_bulk_docs $BULKSIZE $STARTKEY $DOCSIZE) - # echo $DOCS - echo $DOCS | curl -T - -X POST $POSTURL -w%{http_code}\ %{time_total}\ sec\\n >/dev/null 2>&1 & - let POSTS=POSTS+1 - done - - echo "waiting" - wait - let RUN=RUN+1 -done - -curl $DBURL -w\\n diff --git a/test/bench/run.tpl b/test/bench/run.tpl deleted file mode 100755 index 9307863f..00000000 --- a/test/bench/run.tpl +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -e - -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. - -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 - - |