[Pkg-javascript-commits] [node-leveldown] 352/492: added simple throughput write benchmark
Andrew Kelley
andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:14:16 UTC 2014
This is an automated email from the git hooks/post-receive script.
andrewrk-guest pushed a commit to annotated tag rocksdb-0.10.1
in repository node-leveldown.
commit 13b29cc46499137ccfe3aeb6aec1c06645b8129f
Author: Rod Vagg <rod at vagg.org>
Date: Fri Jun 7 20:24:43 2013 +1000
added simple throughput write benchmark
---
bench/write-sorted-plot.sh | 19 ++++++++++++++
bench/write-sorted.js | 65 ++++++++++++++++++++++++++++++++++++++++++++++
package.json | 12 +++++----
3 files changed, 91 insertions(+), 5 deletions(-)
diff --git a/bench/write-sorted-plot.sh b/bench/write-sorted-plot.sh
new file mode 100755
index 0000000..851f152
--- /dev/null
+++ b/bench/write-sorted-plot.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+gnuplot <<EOF
+ reset
+ set terminal png size 1600, 1000
+ set output "write_sorted_times.png"
+ set datafile separator ','
+
+ set yrange [0:0.6]
+
+ set xlabel "Seconds"
+ set ylabel "Milliseconds per write"
+
+ set title "1.3G / 10,000,000 writes"
+ set key below
+ set grid
+
+ plot "write_sorted_times.csv" using (\$1/1000):(\$2/1000000)
+EOF
\ No newline at end of file
diff --git a/bench/write-sorted.js b/bench/write-sorted.js
new file mode 100644
index 0000000..c04d649
--- /dev/null
+++ b/bench/write-sorted.js
@@ -0,0 +1,65 @@
+const leveldown = require('../')
+ , timestamp = require('monotonic-timestamp')
+ , crypto = require('crypto')
+ , fs = require('fs')
+ , du = require('du')
+
+ , entryCount = 10000000
+ , concurrency = 10
+ , timesFile = './write_sorted_times.csv'
+ , dbDir = './write_sorted.db'
+ , data = crypto.randomBytes(256) // buffer
+
+var db = leveldown(dbDir)
+ , timesStream = fs.createWriteStream(timesFile, 'utf8')
+
+function report (ms) {
+ console.log('Wrote', entryCount, 'in', Math.floor(ms / 1000) + 's')
+ timesStream.end()
+ du(dbDir, function (err, size) {
+ if (err)
+ throw err
+ console.log('Database size:', Math.floor(size / 1024 / 1024) + 'M')
+ })
+ console.log('Wrote times to ', timesFile)
+}
+
+db.open({ errorIfExists: true, createIfMissing: true }, function (err) {
+ if (err)
+ throw err
+
+ var inProgress = 0
+ , totalWrites = 0
+ , startTime = Date.now()
+ , timesTotal = 0
+
+ function write() {
+ if (totalWrites % 100000 == 0) console.log(totalWrites)
+
+ if (totalWrites % 1000 == 0) {
+ timesStream.write((Date.now() - startTime) + ',' + Math.floor(timesTotal / 1000) + '\n')
+ timesTotal = 0
+ }
+
+ if (totalWrites++ == entryCount)
+ return report(Date.now() - startTime)
+
+ if (inProgress >= concurrency || totalWrites > entryCount)
+ return
+
+ var time = process.hrtime()
+ inProgress++
+
+ db.put(timestamp(), data, function (err) {
+ if (err)
+ throw err
+ timesTotal += process.hrtime(time)[1]
+ inProgress--
+ process.nextTick(write)
+ })
+
+ process.nextTick(write)
+ }
+
+ write()
+})
\ No newline at end of file
diff --git a/package.json b/package.json
index fdc214d..c723c89 100644
--- a/package.json
+++ b/package.json
@@ -23,11 +23,13 @@
"bindings" : "~1.1.0"
}
, "devDependencies" : {
- "tap" : "~0.4.1"
- , "rimraf" : "~2.1.4"
- , "mkfiletree" : "~0.0.0"
- , "readfiletree" : "~0.0.0"
- , "abstract-leveldown" : "~0.7.0"
+ "tap" : "~0.4.1"
+ , "rimraf" : "~2.1.4"
+ , "mkfiletree" : "~0.0.0"
+ , "readfiletree" : "~0.0.0"
+ , "abstract-leveldown" : "~0.7.0"
+ , "monotonic-timestamp" : "~0.0.8"
+ , "du" : "~0.0.1"
}
, "repository" : {
"type" : "git"
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-leveldown.git
More information about the Pkg-javascript-commits
mailing list