[Pkg-javascript-commits] [node-leveldown] 353/492: added random write bench

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 4eea1ae74fc19057c53c7cb1f0a3f91b30538f2a
Author: Rod Vagg <rod at vagg.org>
Date:   Sun Jun 9 20:53:41 2013 +1000

    added random write bench
---
 bench/write-random-plot.sh                 | 22 ++++++++++++++++++++++
 bench/{write-sorted.js => write-random.js} | 22 +++++++++++++---------
 bench/write-sorted-plot.sh                 |  9 ++++++---
 bench/write-sorted.js                      | 14 +++++++++-----
 4 files changed, 50 insertions(+), 17 deletions(-)

diff --git a/bench/write-random-plot.sh b/bench/write-random-plot.sh
new file mode 100755
index 0000000..6180456
--- /dev/null
+++ b/bench/write-random-plot.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+gnuplot <<EOF
+  reset
+  set terminal png size 1920, 1080
+  set output "write_random_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_random_times_g.csv" using (\$1/1000):(\$2/1000000) title "Google LevelDB" lc rgb "red" lt 7 ps 0.3, \
+       "write_random_times_h.csv" using (\$1/1000):(\$2/1000000) title "HyperDex LevelDB" lc rgb "green" lt 7 ps 0.3, \
+       "write_random_times_b.csv" using (\$1/1000):(\$2/1000000) title "Basho LevelDB" lc rgb "blue" lt 7 ps 0.3
+
+EOF
\ No newline at end of file
diff --git a/bench/write-sorted.js b/bench/write-random.js
similarity index 67%
copy from bench/write-sorted.js
copy to bench/write-random.js
index c04d649..ff32025 100644
--- a/bench/write-sorted.js
+++ b/bench/write-random.js
@@ -1,13 +1,13 @@
 const leveldown   = require('../')
-    , timestamp   = require('monotonic-timestamp')
     , crypto      = require('crypto')
     , fs          = require('fs')
     , du          = require('du')
+    , uuid        = require('node-uuid')
 
     , entryCount  = 10000000
     , concurrency = 10
-    , timesFile   = './write_sorted_times.csv'
-    , dbDir       = './write_sorted.db'
+    , timesFile   = './write_random_times.csv'
+    , dbDir       = './write_random.db'
     , data        = crypto.randomBytes(256) // buffer
 
 var db          = leveldown(dbDir)
@@ -31,14 +31,17 @@ db.open({ errorIfExists: true, createIfMissing: true }, function (err) {
   var inProgress  = 0
     , totalWrites = 0
     , startTime   = Date.now()
-    , timesTotal  = 0
+    //, timesTotal  = 0
+    , writeBuf    = ''
 
   function write() {
-    if (totalWrites % 100000 == 0) console.log(totalWrites)
+    if (totalWrites % 100000 == 0) console.log(inProgress, totalWrites)
 
     if (totalWrites % 1000 == 0) {
-      timesStream.write((Date.now() - startTime) + ',' + Math.floor(timesTotal / 1000) + '\n')
-      timesTotal = 0
+      //timesStream.write((Date.now() - startTime) + ',' + Math.floor(timesTotal / 1000) + '\n')
+      //timesTotal = 0
+      timesStream.write(writeBuf)
+      writeBuf = ''
     }
 
     if (totalWrites++ == entryCount)
@@ -50,10 +53,11 @@ db.open({ errorIfExists: true, createIfMissing: true }, function (err) {
     var time = process.hrtime()
     inProgress++
 
-    db.put(timestamp(), data, function (err) {
+    db.put(uuid.v4(), data, function (err) {
       if (err)
         throw err
-      timesTotal += process.hrtime(time)[1]
+      //timesTotal += process.hrtime(time)[1]
+      writeBuf += (Date.now() - startTime) + ',' + process.hrtime(time)[1] + '\n'
       inProgress--
       process.nextTick(write)
     })
diff --git a/bench/write-sorted-plot.sh b/bench/write-sorted-plot.sh
index 851f152..24ee173 100755
--- a/bench/write-sorted-plot.sh
+++ b/bench/write-sorted-plot.sh
@@ -2,11 +2,11 @@
 
 gnuplot <<EOF
   reset
-  set terminal png size 1600, 1000
+  set terminal png size 1920, 1080
   set output "write_sorted_times.png"
   set datafile separator ','
 
-  set yrange [0:0.6]
+  #set yrange [0:0.6]
 
   set xlabel "Seconds"
   set ylabel "Milliseconds per write"
@@ -15,5 +15,8 @@ gnuplot <<EOF
   set key below
   set grid
 
-  plot "write_sorted_times.csv" using (\$1/1000):(\$2/1000000)
+  plot "write_sorted_times_g.csv" using (\$1/1000):(\$2/1000000) title "Google LevelDB" lc rgb "red" lt 7 ps 0.3, \
+       "write_sorted_times_h.csv" using (\$1/1000):(\$2/1000000) title "HyperDex LevelDB" lc rgb "green" lt 7 ps 0.3, \
+       "write_sorted_times_b.csv" using (\$1/1000):(\$2/1000000) title "Basho LevelDB" lc rgb "blue" lt 7 ps 0.3
+
 EOF
\ No newline at end of file
diff --git a/bench/write-sorted.js b/bench/write-sorted.js
index c04d649..766c2d4 100644
--- a/bench/write-sorted.js
+++ b/bench/write-sorted.js
@@ -31,14 +31,17 @@ db.open({ errorIfExists: true, createIfMissing: true }, function (err) {
   var inProgress  = 0
     , totalWrites = 0
     , startTime   = Date.now()
-    , timesTotal  = 0
+    //, timesTotal  = 0
+    , writeBuf    = ''
 
   function write() {
-    if (totalWrites % 100000 == 0) console.log(totalWrites)
+    if (totalWrites % 100000 == 0) console.log(inProgress, totalWrites)
 
     if (totalWrites % 1000 == 0) {
-      timesStream.write((Date.now() - startTime) + ',' + Math.floor(timesTotal / 1000) + '\n')
-      timesTotal = 0
+      //timesStream.write((Date.now() - startTime) + ',' + Math.floor(timesTotal / 1000) + '\n')
+      //timesTotal = 0
+      timesStream.write(writeBuf)
+      writeBuf = ''
     }
 
     if (totalWrites++ == entryCount)
@@ -53,7 +56,8 @@ db.open({ errorIfExists: true, createIfMissing: true }, function (err) {
     db.put(timestamp(), data, function (err) {
       if (err)
         throw err
-      timesTotal += process.hrtime(time)[1]
+      //timesTotal += process.hrtime(time)[1]
+      writeBuf += (Date.now() - startTime) + ',' + process.hrtime(time)[1] + '\n'
       inProgress--
       process.nextTick(write)
     })

-- 
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