mongo-ruby-driver/bench/exp_series.html

149 lines
6.4 KiB
HTML
Raw Normal View History

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Exp Series Performance Tests</title>
<!-- http://code.google.com/p/flot/ -->
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="excanvas.min.js"></script><![endif]-->
<script language="javascript" type="text/javascript" src="jquery.js"></script>
<script language="javascript" type="text/javascript" src="jquery.flot.js"></script>
<script language="javascript" type="text/javascript" src="exp_series.js"></script>
<style type="text/css">
body {
font-family: sans-serif;
font-size: 16px;
margin: 50px;
max-width: 1000px;
}
div.graph {
width:800px;
height:400px;
}
</style>
</head>
<body>
<h1>Exp Series Performance Tests</h1>
2012-04-17 13:25:11 +00:00
x-axis is power of 2, log base 2 of size<br>
y-axis is operations per user-time CPU-second<br>
Note that this is not operations per real-time second that include DB real-time<br>
<div id="placeholder"></div>
<script type="text/javascript">
2012-04-16 21:28:48 +00:00
function genOpXY(a, xMax, plotSpec, xKey, yKey) {
var genOpA = $.grep(a, function(e, i){
if (e.exp2 > xMax) return false;
for (var key in plotSpec) {
if (e[key] != plotSpec[key]) return false;
}
return true;
});
return $.map(genOpA, function(e, i){return [[e[xKey], e[yKey]]];});
}
2012-04-17 13:25:11 +00:00
function flotSeries(expSeries, xMax, labelSpec, plotSpecs) {
2012-04-16 21:28:48 +00:00
return $.map(plotSpecs, function(plotSpec, i){
var base = plotSpec.base; var gen = plotSpec.generator; var op = plotSpec.operation;
return {
2012-04-17 13:25:11 +00:00
label: labelSpec + ': ' + plotSpec[labelSpec],
2012-04-16 21:28:48 +00:00
data: genOpXY(expSeries, xMax, plotSpec, 'exp2', 'ops'),
lines: { show: true },
points: { show: true }
};
});
}
$(function () {
function xExpTicks(axis) {
var res = [];
for (var i = axis.min; i <= axis.max; i++) {
res.push([i, i + ':' + Math.pow(2,i)]);
}
return res;
}
function doPlot(title, series) {
var id = title.replace(/\W/g,'_');
$("#placeholder").append('<h1>' + title + '</h1><div id="' + id + '" class="graph"></div>');
$.plot($('#' + id),
series,
{
xaxis: { ticks: xExpTicks },
yaxes: [ { min: 0 } ],
legend: { position: 'ne' }
});
}
// comment pending
var graph = [
2012-04-17 13:25:11 +00:00
[ 'value_string_size insert C versus Ruby', 14, 'mongo_driver_mode',
2012-04-16 21:28:48 +00:00
[
2012-04-17 13:25:11 +00:00
{ base:2, generator:'value_string_size', operation:'insert', mongo_driver_mode: 'c' },
{ base:2, generator:'value_string_size', operation:'insert', mongo_driver_mode: 'ruby' }
]
],
2012-04-17 13:25:11 +00:00
[ 'key_string_size insert C versus Ruby', 14, 'mongo_driver_mode',
2012-04-16 21:28:48 +00:00
[
2012-04-17 13:25:11 +00:00
{ base:2, generator:'key_string_size', operation:'insert', mongo_driver_mode: 'c' },
{ base:2, generator:'key_string_size', operation:'insert', mongo_driver_mode: 'ruby' }
]
],
2012-04-17 13:25:11 +00:00
[ 'array_size_fixnum insert C versus Ruby', 12, 'mongo_driver_mode',
2012-04-16 21:28:48 +00:00
[
2012-04-17 13:25:11 +00:00
{ base:2, generator:'array_size_fixnum', operation:'insert', mongo_driver_mode: 'c' },
{ base:2, generator:'array_size_fixnum', operation:'insert', mongo_driver_mode: 'ruby' }
]
],
2012-04-17 13:25:11 +00:00
[ 'hash_size_fixnum insert C versus Ruby', 12, 'mongo_driver_mode',
2012-04-16 21:28:48 +00:00
[
2012-04-17 13:25:11 +00:00
{ base:2, generator:'hash_size_fixnum', operation:'insert', mongo_driver_mode: 'c' },
{ base:2, generator:'hash_size_fixnum', operation:'insert', mongo_driver_mode: 'ruby' }
]
],
[ 'array_nest_fixnum base 2 insert C versus Ruby', 12, 'mongo_driver_mode',
[
{ base:2, generator:'array_nest_fixnum', operation:'insert', mongo_driver_mode:'c' },
{ base:2, generator:'array_nest_fixnum', operation:'insert', mongo_driver_mode:'ruby' }
]
],
[ 'hash_nest_fixnum base 2 insert C versus Ruby', 12, 'mongo_driver_mode',
[
{ base:2, generator:'hash_nest_fixnum', operation:'insert', mongo_driver_mode: 'c' },
{ base:2, generator:'hash_nest_fixnum', operation:'insert', mongo_driver_mode: 'ruby' }
]
],
2012-04-17 13:25:11 +00:00
[ 'array_nest_fixnum insert C by base', 12, 'base',
2012-04-16 21:28:48 +00:00
[
{ base:2, generator:'array_nest_fixnum', operation:'insert', mongo_driver_mode: 'c' },
{ base:4, generator:'array_nest_fixnum', operation:'insert', mongo_driver_mode: 'c' },
{ base:8, generator:'array_nest_fixnum', operation:'insert', mongo_driver_mode: 'c' },
{ base:16, generator:'array_nest_fixnum', operation:'insert', mongo_driver_mode: 'c' },
{ base:32, generator:'array_nest_fixnum', operation:'insert', mongo_driver_mode: 'c' }
]
],
2012-04-17 13:25:11 +00:00
[ 'hash_nest_fixnum insert C by base', 12, 'base',
2012-04-16 21:28:48 +00:00
[
{ base:2, generator:'hash_nest_fixnum', operation:'insert', mongo_driver_mode: 'c' },
{ base:4, generator:'hash_nest_fixnum', operation:'insert', mongo_driver_mode: 'c' },
{ base:8, generator:'hash_nest_fixnum', operation:'insert', mongo_driver_mode: 'c' },
{ base:16, generator:'hash_nest_fixnum', operation:'insert', mongo_driver_mode: 'c' },
{ base:32, generator:'hash_nest_fixnum', operation:'insert', mongo_driver_mode: 'c' }
]
],
2012-04-17 13:25:11 +00:00
[ 'array_size_fixnum versus hash_size_fixnum insert C', 12, 'generator',
2012-04-16 21:28:48 +00:00
[
{ base:2, generator:'array_size_fixnum', operation:'insert', mongo_driver_mode: 'c' },
{ base:2, generator:'hash_size_fixnum', operation:'insert', mongo_driver_mode: 'c' }
]
2012-04-16 21:28:48 +00:00
]
];
$.each(graph, function(i, e){
var title, xMax, labelSpec, plotSpecs;
title = e[0]; xMax = e[1]; labelSpec = e[2]; plotSpecs = e[3]; //[title, xMax, labelSpec, plotSpecs] = e;
2012-04-17 13:25:11 +00:00
var series = flotSeries(expSeries, xMax, labelSpec, plotSpecs);
doPlot(title, series);
});
});
</script>
</body>
</html>