From b78afa410415ef710695720d2c437caaf781f100 Mon Sep 17 00:00:00 2001
From: bigbes <bigbes@gmail.com>
Date: Thu, 16 Apr 2015 00:16:32 +0300
Subject: [PATCH] Add memory benchmarks of redis/tarantool with diff.indexes

---
 doc/www/content/js/bench_tabs.js       |  15 ++-
 doc/www/content/js/filesize.min.js     |   6 ++
 doc/www/content/ycsb/MEM.json          | 142 +++++++++++++++++++++++++
 doc/www/pelicanconf.py                 |   1 +
 doc/www/theme/templates/benchmark.html |   2 +
 5 files changed, 163 insertions(+), 3 deletions(-)
 create mode 100644 doc/www/content/js/filesize.min.js
 create mode 100644 doc/www/content/ycsb/MEM.json

diff --git a/doc/www/content/js/bench_tabs.js b/doc/www/content/js/bench_tabs.js
index 2ec46a3569..61845eb7fa 100644
--- a/doc/www/content/js/bench_tabs.js
+++ b/doc/www/content/js/bench_tabs.js
@@ -11,6 +11,8 @@ function create_li(arr) {
     return tmparr.join('');
 }
 
+
+
 (function(){
     var dOn = $(document);
 
@@ -31,11 +33,18 @@ function create_li(arr) {
                     'C': ['READ'],
                     'D': ['READ', 'INSERT'],
                     'E': ['SCAN', 'INSERT'],
-                    'F': ['READ', 'READ-MODIFY-WRITE', 'UPDATE']
+                    'F': ['READ', 'READ-MODIFY-WRITE', 'UPDATE'],
+                    'MEM': []
                 };
                 title.html('Workload ' + link.html());
-                image_1.renderChart('/ycsb/' + link.html() + '_throughput.json');
-                image_2.renderChart('/ycsb/' + link.html() + '_' + table[link.html()][0] + '_latency.json');
+                if (link.html() == 'MEM') {
+                    title.html('Memory footprint')
+                    image_1.renderChart('/ycsb/MEM.json');
+                    image_2.highcharts().destroy()
+                } else {
+                    image_1.renderChart('/ycsb/' + link.html() + '_throughput.json');
+                    image_2.renderChart('/ycsb/' + link.html() + '_' + table[link.html()][0] + '_latency.json');
+                }
                 ul.html(create_li(table[link.html()]));
             }
         }
diff --git a/doc/www/content/js/filesize.min.js b/doc/www/content/js/filesize.min.js
new file mode 100644
index 0000000000..4543deb487
--- /dev/null
+++ b/doc/www/content/js/filesize.min.js
@@ -0,0 +1,6 @@
+/*
+ 2015 Jason Mulligan
+ @version 3.1.2
+ */
+"use strict";!function(a){var b=/b$/,c={bits:["B","kb","Mb","Gb","Tb","Pb","Eb","Zb","Yb"],bytes:["B","kB","MB","GB","TB","PB","EB","ZB","YB"]},d=function(a){var d=void 0===arguments[1]?{}:arguments[1],e=[],f=!1,g=0,h=void 0,i=void 0,j=void 0,k=void 0,l=void 0,m=void 0,n=void 0,o=void 0,p=void 0,q=void 0,r=void 0;if(isNaN(a))throw new Error("Invalid arguments");return j=d.bits===!0,p=d.unix===!0,i=void 0!==d.base?d.base:2,o=void 0!==d.round?d.round:p?1:2,q=void 0!==d.spacer?d.spacer:p?"":" ",r=void 0!==d.suffixes?d.suffixes:{},n=void 0!==d.output?d.output:"string",h=void 0!==d.exponent?d.exponent:-1,m=Number(a),l=0>m,k=i>2?1e3:1024,l&&(m=-m),0===m?(e[0]=0,e[1]=p?"":"B"):((-1===h||isNaN(h))&&(h=Math.floor(Math.log(m)/Math.log(k))),h>8&&(g=1e3*g*(h-8),h=8),g=2===i?m/Math.pow(2,10*h):m/Math.pow(1e3,h),j&&(g=8*g,g>k&&(g/=k,h++)),e[0]=Number(g.toFixed(h>0?o:0)),e[1]=c[j?"bits":"bytes"][h],!f&&p&&(j&&b.test(e[1])&&(e[1]=e[1].toLowerCase()),e[1]=e[1].charAt(0),"B"===e[1]?(e[0]=Math.floor(e[0]),e[1]=""):j||"k"!==e[1]||(e[1]="K"))),l&&(e[0]=-e[0]),e[1]=r[e[1]]||e[1],"array"===n?e:"exponent"===n?h:"object"===n?{value:e[0],suffix:e[1]}:e.join(q)};"undefined"!=typeof exports?module.exports=d:"function"==typeof define?define(function(){return d}):a.filesize=d}("undefined"!=typeof global?global:window);
+//# sourceMappingURL=filesize.min.js.map
\ No newline at end of file
diff --git a/doc/www/content/ycsb/MEM.json b/doc/www/content/ycsb/MEM.json
new file mode 100644
index 0000000000..d40a543336
--- /dev/null
+++ b/doc/www/content/ycsb/MEM.json
@@ -0,0 +1,142 @@
+{
+    "chart": {}, 
+    "credits": {
+        "enabled": false
+    }, 
+    "legend": {}, 
+    "series": [
+        {
+            "color": "#0d233a", 
+            "data": [
+                {
+                    "x": 100000, 
+                    "y": 157392,
+                    "time": 5.177
+                }, 
+                {
+                    "x": 500000, 
+                    "y": 753384,
+                    "time": 24.087
+                }, 
+                {
+                    "x": 1000000, 
+                    "y": 1498856,
+                    "time": 47.118
+                }, 
+                {
+                    "x": 2000000, 
+                    "y": 2991856,
+                    "time": 93.49
+                }, 
+                {
+                    "x": 5000000, 
+                    "y": 7581416,
+                    "time": 125.14
+                }, 
+                {
+                    "x": 10000000, 
+                    "y": 15152876,
+                    "time": 252.44
+                }
+            ], 
+            "name": "Redis 2.8.19", 
+            "type": "line"
+        }, 
+        {
+            "color": "#2f7ed8", 
+            "data": [
+                {
+                    "x": 100000, 
+                    "y": 146664,
+                    "time": 3.114
+                }, 
+                {
+                    "x": 500000, 
+                    "y": 646140,
+                    "time": 13.167
+                }, 
+                {
+                    "x": 1000000, 
+                    "y": 1270848,
+                    "time": 25.341
+                }, 
+                {
+                    "x": 2000000, 
+                    "y": 2511868,
+                    "time": 49.314
+                }, 
+                {
+                    "x": 5000000, 
+                    "y": 6253792,
+                    "time": 125.14
+                }, 
+                {
+                    "x": 10000000, 
+                    "y": 12485828,
+                    "time": 252.44
+                }
+            ], 
+            "name": "Tarantool (HASH, 1.6.4-564-ge6e1429)", 
+            "type": "line"
+        }, 
+        {
+            "color": "#8bbc21", 
+            "data": [
+                {
+                    "x": 100000,
+                    "y": 146488,
+                    "time": 3.247
+                }, 
+                {
+                    "x": 500000, 
+                    "y": 642176,
+                    "time": 13.859
+                }, 
+                {
+                    "x": 1000000, 
+                    "y": 1262672,
+                    "time": 26.81
+                }, 
+                {
+                    "x": 2000000, 
+                    "y": 2497716,
+                    "time": 54.493
+                }, 
+                {
+                    "x": 5000000, 
+                    "y": 6220956,
+                    "time": 138.5
+                }, 
+                {
+                    "x": 10000000, 
+                    "y": 12424376,
+                    "time": 273.93
+                }
+            ], 
+            "name": "Tarantool (TREE, 1.6.4-564-ge6e1429)", 
+            "type": "line"
+        }
+    ], 
+    "subtitle": {
+        "text": "10000 to 10000000 records. Less is better", 
+        "x": -20
+    }, 
+    "title": {
+        "text": "Memory bench", 
+        "x": -20
+    },  
+    "tooltip": {
+        "formatter": "return this.series.name + '<br/>' + this.x + ' records :' + filesize(this.y * 1024)"
+    },
+    "xAxis": {
+        "allowDecimals": false, 
+        "title": {
+            "text": "Records (pcs)"
+        }
+    }, 
+    "yAxis": {
+        "title": {
+            "text": "Memory (kb)"
+        }
+    }
+}
diff --git a/doc/www/pelicanconf.py b/doc/www/pelicanconf.py
index 6048301885..cd779ff635 100644
--- a/doc/www/pelicanconf.py
+++ b/doc/www/pelicanconf.py
@@ -49,6 +49,7 @@ STATIC_PATHS = [
     'js/main.js',
     'js/old_tabs.js',
     'js/select.js',
+    'js/filesize.min.js'
 ]
 
 EXTRA_PATH_METADATA = {}
diff --git a/doc/www/theme/templates/benchmark.html b/doc/www/theme/templates/benchmark.html
index 21478f737c..4ce686ab6e 100644
--- a/doc/www/theme/templates/benchmark.html
+++ b/doc/www/theme/templates/benchmark.html
@@ -3,6 +3,7 @@
 {% block header_scripts %}
 <script src="http://code.highcharts.com/highcharts.js"></script>
 <script src="js/highcharts.js"></script>
+<script src="js/filesize.min.js"></script>
 <script src="js/bench_tabs.js"></script>
 {% endblock header_scripts %}
 
@@ -27,6 +28,7 @@
           <li class="b-switcher-item"><a href="#" class="b-switcher-item-url">D</a></li>
           <li class="b-switcher-item"><a href="#" class="b-switcher-item-url">E</a></li>
           <li class="b-switcher-item"><a href="#" class="b-switcher-item-url">F</a></li>
+          <li class="b-switcher-item"><a href="#" class="b-switcher-item-url">MEM</a></li>
         </ul>
       </div>
       <div class="b-benchmark-type">
-- 
GitLab