[Gary] exp series benchmark tests for performance and profiling
This commit is contained in:
parent
00cea59c10
commit
2390578805
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,119 @@
|
|||
<!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>
|
||||
y-axis is operations per user-time CPU-second
|
||||
<div id="placeholder"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function genOpXY(a, xMax, base, gen, op, xKey, yKey) {
|
||||
var genOpA = $.grep(a, function(e, i){return (e.exp2 <= xMax && e.base == base && e.generator == gen && e.operation == op);});
|
||||
return $.map(genOpA, function(e, i){return [[e[xKey], e[yKey]]];});
|
||||
}
|
||||
function flotSeries(expSeries, xMax, a) {
|
||||
return $.map(a, function(e, i){
|
||||
var base = e[0]; gen = e[1]; var op = e[2];
|
||||
return {
|
||||
label: gen + '-' + base,
|
||||
data: genOpXY(expSeries, xMax, base, gen, op, '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 = [
|
||||
[ 'value_string_size insert', 14, [
|
||||
[2, 'value_string_size', 'insert']
|
||||
]
|
||||
],
|
||||
[ 'key_string_size insert', 14, [
|
||||
[2, 'key_string_size', 'insert']
|
||||
]
|
||||
],
|
||||
[ 'array_size_fixnum insert', 12, [
|
||||
[2, 'array_size_fixnum', 'insert']
|
||||
]
|
||||
],
|
||||
[ 'hash_size_fixnum insert', 12, [
|
||||
[2, 'hash_size_fixnum', 'insert']
|
||||
]
|
||||
],
|
||||
[ 'array_nest_fixnum insert', 12, [
|
||||
[2, 'array_nest_fixnum', 'insert'],
|
||||
[4, 'array_nest_fixnum', 'insert'],
|
||||
[8, 'array_nest_fixnum', 'insert'],
|
||||
[16, 'array_nest_fixnum', 'insert'],
|
||||
[32, 'array_nest_fixnum', 'insert']
|
||||
]
|
||||
],
|
||||
[ 'hash_nest_fixnum insert', 12, [
|
||||
[2, 'hash_nest_fixnum', 'insert'],
|
||||
[4, 'hash_nest_fixnum', 'insert'],
|
||||
[8, 'hash_nest_fixnum', 'insert'],
|
||||
[16, 'hash_nest_fixnum', 'insert'],
|
||||
[32, 'hash_nest_fixnum', 'insert']
|
||||
]
|
||||
],
|
||||
[ 'compare array_size_fixnum hash_size_fixnum insert', 12, [
|
||||
[2, 'array_size_fixnum', 'insert'],
|
||||
[2, 'hash_size_fixnum', 'insert']
|
||||
]
|
||||
],
|
||||
|
||||
];
|
||||
$.each(graph, function(i, e){
|
||||
var title = e[0];
|
||||
var xMax = e[1];
|
||||
var baseSeriesGenOp = e[2];
|
||||
var series = flotSeries(expSeries, xMax, baseSeriesGenOp);
|
||||
doPlot(title, series);
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,137 @@
|
|||
expSeries = [
|
||||
{"base":2,"power":0,"size":1,"exp2":0,"generator":"value_string_size","operation":"insert","iterations":136533,"utime":10.05,"etime":2.18,"rtime":13.99,"ops":13585.4,"usec":73.6},
|
||||
{"base":2,"power":1,"size":2,"exp2":1,"generator":"value_string_size","operation":"insert","iterations":136533,"utime":10.0,"etime":2.82,"rtime":12.5,"ops":13653.3,"usec":73.2},
|
||||
{"base":2,"power":2,"size":4,"exp2":2,"generator":"value_string_size","operation":"insert","iterations":136533,"utime":10.09,"etime":2.79,"rtime":14.45,"ops":13531.5,"usec":73.9},
|
||||
{"base":2,"power":3,"size":8,"exp2":3,"generator":"value_string_size","operation":"insert","iterations":136533,"utime":10.0,"etime":2.87,"rtime":12.39,"ops":13653.3,"usec":73.2},
|
||||
{"base":2,"power":4,"size":16,"exp2":4,"generator":"value_string_size","operation":"insert","iterations":136533,"utime":9.95,"etime":2.98,"rtime":12.09,"ops":13721.9,"usec":72.9},
|
||||
{"base":2,"power":5,"size":32,"exp2":5,"generator":"value_string_size","operation":"insert","iterations":136533,"utime":10.04,"etime":2.9,"rtime":12.73,"ops":13598.9,"usec":73.5},
|
||||
{"base":2,"power":6,"size":64,"exp2":6,"generator":"value_string_size","operation":"insert","iterations":136533,"utime":10.23,"etime":3.58,"rtime":15.43,"ops":13346.3,"usec":74.9},
|
||||
{"base":2,"power":7,"size":128,"exp2":7,"generator":"value_string_size","operation":"insert","iterations":136533,"utime":10.19,"etime":3.49,"rtime":12.44,"ops":13398.7,"usec":74.6},
|
||||
{"base":2,"power":8,"size":256,"exp2":8,"generator":"value_string_size","operation":"insert","iterations":136533,"utime":10.71,"etime":3.74,"rtime":17.6,"ops":12748.2,"usec":78.4},
|
||||
{"base":2,"power":9,"size":512,"exp2":9,"generator":"value_string_size","operation":"insert","iterations":127999,"utime":9.92,"etime":3.86,"rtime":16.04,"ops":12903.1,"usec":77.5},
|
||||
{"base":2,"power":10,"size":1024,"exp2":10,"generator":"value_string_size","operation":"insert","iterations":127999,"utime":10.39,"etime":5.85,"rtime":13.78,"ops":12319.4,"usec":81.2},
|
||||
{"base":2,"power":11,"size":2048,"exp2":11,"generator":"value_string_size","operation":"insert","iterations":113777,"utime":10.32,"etime":4.67,"rtime":17.28,"ops":11024.9,"usec":90.7},
|
||||
{"base":2,"power":12,"size":4096,"exp2":12,"generator":"value_string_size","operation":"insert","iterations":102399,"utime":10.47,"etime":21.54,"rtime":20.57,"ops":9780.2,"usec":102.2},
|
||||
{"base":2,"power":13,"size":8192,"exp2":13,"generator":"value_string_size","operation":"insert","iterations":73142,"utime":9.61,"etime":9.64,"rtime":18.79,"ops":7611.0,"usec":131.4},
|
||||
{"base":2,"power":14,"size":16384,"exp2":14,"generator":"value_string_size","operation":"insert","iterations":51200,"utime":10.02,"etime":9.1,"rtime":107.18,"ops":5109.8,"usec":195.7},
|
||||
{"base":2,"power":15,"size":32768,"exp2":15,"generator":"value_string_size","operation":"insert","iterations":34133,"utime":10.8,"etime":9.43,"rtime":169.25,"ops":3160.5,"usec":316.4},
|
||||
{"base":2,"power":0,"size":1,"exp2":0,"generator":"key_string_size","operation":"insert","iterations":128000,"utime":9.29,"etime":37.42,"rtime":12.43,"ops":13778.3,"usec":72.6},
|
||||
{"base":2,"power":1,"size":2,"exp2":1,"generator":"key_string_size","operation":"insert","iterations":136533,"utime":9.88,"etime":5.55,"rtime":12.64,"ops":13819.1,"usec":72.4},
|
||||
{"base":2,"power":2,"size":4,"exp2":2,"generator":"key_string_size","operation":"insert","iterations":146285,"utime":10.62,"etime":7.39,"rtime":13.45,"ops":13774.5,"usec":72.6},
|
||||
{"base":2,"power":3,"size":8,"exp2":3,"generator":"key_string_size","operation":"insert","iterations":146285,"utime":11.03,"etime":4.05,"rtime":15.9,"ops":13262.5,"usec":75.4},
|
||||
{"base":2,"power":4,"size":16,"exp2":4,"generator":"key_string_size","operation":"insert","iterations":128000,"utime":10.45,"etime":3.92,"rtime":17.96,"ops":12248.8,"usec":81.6},
|
||||
{"base":2,"power":5,"size":32,"exp2":5,"generator":"key_string_size","operation":"insert","iterations":128000,"utime":10.26,"etime":5.27,"rtime":13.0,"ops":12475.6,"usec":80.2},
|
||||
{"base":2,"power":6,"size":64,"exp2":6,"generator":"key_string_size","operation":"insert","iterations":136533,"utime":10.96,"etime":3.59,"rtime":17.6,"ops":12457.4,"usec":80.3},
|
||||
{"base":2,"power":7,"size":128,"exp2":7,"generator":"key_string_size","operation":"insert","iterations":136533,"utime":10.67,"etime":4.46,"rtime":19.46,"ops":12796.0,"usec":78.1},
|
||||
{"base":2,"power":8,"size":256,"exp2":8,"generator":"key_string_size","operation":"insert","iterations":128000,"utime":9.83,"etime":11.72,"rtime":18.71,"ops":13021.4,"usec":76.8},
|
||||
{"base":2,"power":9,"size":512,"exp2":9,"generator":"key_string_size","operation":"insert","iterations":127999,"utime":10.16,"etime":6.84,"rtime":20.55,"ops":12598.3,"usec":79.4},
|
||||
{"base":2,"power":10,"size":1024,"exp2":10,"generator":"key_string_size","operation":"insert","iterations":120470,"utime":10.08,"etime":5.47,"rtime":16.68,"ops":11951.4,"usec":83.7},
|
||||
{"base":2,"power":11,"size":2048,"exp2":11,"generator":"key_string_size","operation":"insert","iterations":107789,"utime":10.05,"etime":6.64,"rtime":16.54,"ops":10725.3,"usec":93.2},
|
||||
{"base":2,"power":12,"size":4096,"exp2":12,"generator":"key_string_size","operation":"insert","iterations":85333,"utime":9.09,"etime":8.32,"rtime":46.2,"ops":9387.6,"usec":106.5},
|
||||
{"base":2,"power":13,"size":8192,"exp2":13,"generator":"key_string_size","operation":"insert","iterations":68266,"utime":9.84,"etime":7.96,"rtime":154.74,"ops":6937.6,"usec":144.1},
|
||||
{"base":2,"power":14,"size":16384,"exp2":14,"generator":"key_string_size","operation":"insert","iterations":46545,"utime":10.03,"etime":74.96,"rtime":33.71,"ops":4640.6,"usec":215.5},
|
||||
{"base":2,"power":15,"size":32768,"exp2":15,"generator":"key_string_size","operation":"insert","iterations":28444,"utime":10.67,"etime":69.27,"rtime":245.7,"ops":2665.8,"usec":375.1},
|
||||
{"base":2,"power":0,"size":1,"exp2":0,"generator":"array_size_fixnum","operation":"insert","iterations":128000,"utime":10.07,"etime":21.69,"rtime":13.13,"ops":12711.0,"usec":78.7},
|
||||
{"base":2,"power":1,"size":2,"exp2":1,"generator":"array_size_fixnum","operation":"insert","iterations":113777,"utime":9.99,"etime":4.61,"rtime":12.78,"ops":11389.1,"usec":87.8},
|
||||
{"base":2,"power":2,"size":4,"exp2":2,"generator":"array_size_fixnum","operation":"insert","iterations":107789,"utime":10.11,"etime":4.46,"rtime":13.33,"ops":10661.6,"usec":93.8},
|
||||
{"base":2,"power":3,"size":8,"exp2":3,"generator":"array_size_fixnum","operation":"insert","iterations":93090,"utime":11.0,"etime":4.18,"rtime":14.32,"ops":8462.7,"usec":118.2},
|
||||
{"base":2,"power":4,"size":16,"exp2":4,"generator":"array_size_fixnum","operation":"insert","iterations":60235,"utime":10.01,"etime":2.99,"rtime":12.49,"ops":6017.5,"usec":166.2},
|
||||
{"base":2,"power":5,"size":32,"exp2":5,"generator":"array_size_fixnum","operation":"insert","iterations":36571,"utime":9.42,"etime":2.46,"rtime":11.19,"ops":3882.3,"usec":257.6},
|
||||
{"base":2,"power":6,"size":64,"exp2":6,"generator":"array_size_fixnum","operation":"insert","iterations":23272,"utime":10.3,"etime":1.21,"rtime":12.05,"ops":2259.4,"usec":442.6},
|
||||
{"base":2,"power":7,"size":128,"exp2":7,"generator":"array_size_fixnum","operation":"insert","iterations":11636,"utime":9.36,"etime":1.36,"rtime":11.08,"ops":1243.2,"usec":804.4},
|
||||
{"base":2,"power":8,"size":256,"exp2":8,"generator":"array_size_fixnum","operation":"insert","iterations":6399,"utime":9.77,"etime":1.64,"rtime":11.52,"ops":655.0,"usec":1526.8},
|
||||
{"base":2,"power":9,"size":512,"exp2":9,"generator":"array_size_fixnum","operation":"insert","iterations":3199,"utime":9.56,"etime":1.11,"rtime":36.91,"ops":334.6,"usec":2988.4},
|
||||
{"base":2,"power":10,"size":1024,"exp2":10,"generator":"array_size_fixnum","operation":"insert","iterations":1599,"utime":9.56,"etime":0.29,"rtime":37.42,"ops":167.3,"usec":5978.7},
|
||||
{"base":2,"power":11,"size":2048,"exp2":11,"generator":"array_size_fixnum","operation":"insert","iterations":888,"utime":10.28,"etime":0.39,"rtime":12.27,"ops":86.4,"usec":11576.6},
|
||||
{"base":2,"power":12,"size":4096,"exp2":12,"generator":"array_size_fixnum","operation":"insert","iterations":399,"utime":9.25,"etime":0.23,"rtime":12.18,"ops":43.1,"usec":23183.0},
|
||||
{"base":2,"power":13,"size":8192,"exp2":13,"generator":"array_size_fixnum","operation":"insert","iterations":222,"utime":10.27,"etime":0.54,"rtime":14.75,"ops":21.6,"usec":46261.3},
|
||||
{"base":2,"power":14,"size":16384,"exp2":14,"generator":"array_size_fixnum","operation":"insert","iterations":111,"utime":10.16,"etime":0.43,"rtime":49.32,"ops":10.9,"usec":91531.5},
|
||||
{"base":2,"power":0,"size":1,"exp2":0,"generator":"hash_size_fixnum","operation":"insert","iterations":146285,"utime":10.73,"etime":0.38,"rtime":15.22,"ops":13633.3,"usec":73.3},
|
||||
{"base":2,"power":1,"size":2,"exp2":1,"generator":"hash_size_fixnum","operation":"insert","iterations":136533,"utime":9.91,"etime":9.02,"rtime":14.61,"ops":13777.3,"usec":72.6},
|
||||
{"base":2,"power":2,"size":4,"exp2":2,"generator":"hash_size_fixnum","operation":"insert","iterations":146285,"utime":10.78,"etime":4.55,"rtime":15.01,"ops":13570.0,"usec":73.7},
|
||||
{"base":2,"power":3,"size":8,"exp2":3,"generator":"hash_size_fixnum","operation":"insert","iterations":136533,"utime":10.25,"etime":4.34,"rtime":15.26,"ops":13320.3,"usec":75.1},
|
||||
{"base":2,"power":4,"size":16,"exp2":4,"generator":"hash_size_fixnum","operation":"insert","iterations":120470,"utime":9.77,"etime":6.15,"rtime":14.85,"ops":12330.6,"usec":81.1},
|
||||
{"base":2,"power":5,"size":32,"exp2":5,"generator":"hash_size_fixnum","operation":"insert","iterations":113777,"utime":9.76,"etime":4.1,"rtime":17.57,"ops":11657.5,"usec":85.8},
|
||||
{"base":2,"power":6,"size":64,"exp2":6,"generator":"hash_size_fixnum","operation":"insert","iterations":102399,"utime":10.33,"etime":5.1,"rtime":33.75,"ops":9912.8,"usec":100.9},
|
||||
{"base":2,"power":7,"size":128,"exp2":7,"generator":"hash_size_fixnum","operation":"insert","iterations":78769,"utime":9.81,"etime":7.31,"rtime":25.05,"ops":8029.5,"usec":124.5},
|
||||
{"base":2,"power":8,"size":256,"exp2":8,"generator":"hash_size_fixnum","operation":"insert","iterations":51199,"utime":8.82,"etime":7.33,"rtime":33.57,"ops":5804.9,"usec":172.3},
|
||||
{"base":2,"power":9,"size":512,"exp2":9,"generator":"hash_size_fixnum","operation":"insert","iterations":36571,"utime":9.93,"etime":8.05,"rtime":43.05,"ops":3682.9,"usec":271.5},
|
||||
{"base":2,"power":10,"size":1024,"exp2":10,"generator":"hash_size_fixnum","operation":"insert","iterations":21333,"utime":10.28,"etime":6.04,"rtime":37.91,"ops":2075.2,"usec":481.9},
|
||||
{"base":2,"power":11,"size":2048,"exp2":11,"generator":"hash_size_fixnum","operation":"insert","iterations":12799,"utime":11.29,"etime":2.99,"rtime":32.58,"ops":1133.7,"usec":882.1},
|
||||
{"base":2,"power":12,"size":4096,"exp2":12,"generator":"hash_size_fixnum","operation":"insert","iterations":5818,"utime":10.45,"etime":1.37,"rtime":76.14,"ops":556.7,"usec":1796.1},
|
||||
{"base":2,"power":13,"size":8192,"exp2":13,"generator":"hash_size_fixnum","operation":"insert","iterations":2461,"utime":10.44,"etime":1.42,"rtime":47.07,"ops":235.7,"usec":4242.2},
|
||||
{"base":2,"power":14,"size":16384,"exp2":14,"generator":"hash_size_fixnum","operation":"insert","iterations":727,"utime":8.67,"etime":0.93,"rtime":21.97,"ops":83.9,"usec":11925.7},
|
||||
{"base":2,"power":15,"size":32768,"exp2":15,"generator":"hash_size_fixnum","operation":"insert","iterations":615,"utime":10.13,"etime":1.25,"rtime":34.35,"ops":60.7,"usec":16471.5},
|
||||
{"base":2,"power":16,"size":65536,"exp2":16,"generator":"hash_size_fixnum","operation":"insert","iterations":333,"utime":10.4,"etime":1.29,"rtime":38.32,"ops":32.0,"usec":31231.2},
|
||||
{"base":2,"power":17,"size":131072,"exp2":17,"generator":"hash_size_fixnum","operation":"insert","iterations":125,"utime":8.95,"etime":0.83,"rtime":117.84,"ops":14.0,"usec":71600.0},
|
||||
{"base":2,"power":0,"size":1,"exp2":0,"generator":"array_nest_fixnum","operation":"insert","iterations":146285,"utime":9.95,"etime":0.45,"rtime":18.79,"ops":14702.0,"usec":68.0},
|
||||
{"base":2,"power":1,"size":2,"exp2":1,"generator":"array_nest_fixnum","operation":"insert","iterations":120470,"utime":10.06,"etime":6.83,"rtime":12.96,"ops":11975.1,"usec":83.5},
|
||||
{"base":2,"power":2,"size":4,"exp2":2,"generator":"array_nest_fixnum","operation":"insert","iterations":93090,"utime":10.29,"etime":5.96,"rtime":19.01,"ops":9046.6,"usec":110.5},
|
||||
{"base":2,"power":3,"size":8,"exp2":3,"generator":"array_nest_fixnum","operation":"insert","iterations":56888,"utime":9.32,"etime":4.96,"rtime":229.02,"ops":6103.9,"usec":163.8},
|
||||
{"base":2,"power":4,"size":16,"exp2":4,"generator":"array_nest_fixnum","operation":"insert","iterations":36571,"utime":9.8,"etime":3.13,"rtime":11.34,"ops":3731.7,"usec":268.0},
|
||||
{"base":2,"power":5,"size":32,"exp2":5,"generator":"array_nest_fixnum","operation":"insert","iterations":19692,"utime":9.41,"etime":1.41,"rtime":49.94,"ops":2092.7,"usec":477.9},
|
||||
{"base":2,"power":6,"size":64,"exp2":6,"generator":"array_nest_fixnum","operation":"insert","iterations":10666,"utime":9.47,"etime":1.96,"rtime":16.72,"ops":1126.3,"usec":887.9},
|
||||
{"base":2,"power":7,"size":128,"exp2":7,"generator":"array_nest_fixnum","operation":"insert","iterations":5818,"utime":9.94,"etime":0.64,"rtime":18.24,"ops":585.3,"usec":1708.5},
|
||||
{"base":2,"power":8,"size":256,"exp2":8,"generator":"array_nest_fixnum","operation":"insert","iterations":2909,"utime":9.63,"etime":0.99,"rtime":11.05,"ops":302.1,"usec":3310.4},
|
||||
{"base":2,"power":9,"size":512,"exp2":9,"generator":"array_nest_fixnum","operation":"insert","iterations":1454,"utime":9.68,"etime":0.73,"rtime":19.38,"ops":150.2,"usec":6657.5},
|
||||
{"base":2,"power":10,"size":1024,"exp2":10,"generator":"array_nest_fixnum","operation":"insert","iterations":727,"utime":9.63,"etime":0.23,"rtime":10.92,"ops":75.5,"usec":13246.2},
|
||||
{"base":2,"power":11,"size":2048,"exp2":11,"generator":"array_nest_fixnum","operation":"insert","iterations":363,"utime":9.44,"etime":0.21,"rtime":10.43,"ops":38.5,"usec":26005.5},
|
||||
{"base":2,"power":12,"size":4096,"exp2":12,"generator":"array_nest_fixnum","operation":"insert","iterations":181,"utime":9.32,"etime":0.17,"rtime":9.94,"ops":19.4,"usec":51491.7},
|
||||
{"base":4,"power":0,"size":1,"exp2":0,"generator":"array_nest_fixnum","operation":"insert","iterations":157538,"utime":10.86,"etime":0.36,"rtime":14.97,"ops":14506.3,"usec":68.9},
|
||||
{"base":4,"power":1,"size":4,"exp2":2,"generator":"array_nest_fixnum","operation":"insert","iterations":102399,"utime":9.91,"etime":9.4,"rtime":12.8,"ops":10332.9,"usec":96.8},
|
||||
{"base":4,"power":2,"size":16,"exp2":4,"generator":"array_nest_fixnum","operation":"insert","iterations":51199,"utime":10.38,"etime":4.53,"rtime":12.14,"ops":4932.5,"usec":202.7},
|
||||
{"base":4,"power":3,"size":64,"exp2":6,"generator":"array_nest_fixnum","operation":"insert","iterations":16000,"utime":9.83,"etime":2.13,"rtime":10.66,"ops":1627.7,"usec":614.4},
|
||||
{"base":4,"power":4,"size":256,"exp2":8,"generator":"array_nest_fixnum","operation":"insert","iterations":3999,"utime":9.08,"etime":0.92,"rtime":33.64,"ops":440.4,"usec":2270.6},
|
||||
{"base":4,"power":5,"size":1024,"exp2":10,"generator":"array_nest_fixnum","operation":"insert","iterations":1142,"utime":10.01,"etime":0.73,"rtime":11.07,"ops":114.1,"usec":8765.3},
|
||||
{"base":4,"power":6,"size":4096,"exp2":12,"generator":"array_nest_fixnum","operation":"insert","iterations":307,"utime":10.51,"etime":0.27,"rtime":11.15,"ops":29.2,"usec":34234.5},
|
||||
{"base":8,"power":0,"size":1,"exp2":0,"generator":"array_nest_fixnum","operation":"insert","iterations":136533,"utime":9.35,"etime":0.36,"rtime":12.96,"ops":14602.5,"usec":68.5},
|
||||
{"base":8,"power":1,"size":8,"exp2":3,"generator":"array_nest_fixnum","operation":"insert","iterations":85333,"utime":10.54,"etime":11.18,"rtime":12.79,"ops":8096.1,"usec":123.5},
|
||||
{"base":8,"power":2,"size":64,"exp2":6,"generator":"array_nest_fixnum","operation":"insert","iterations":18285,"utime":9.95,"etime":3.08,"rtime":12.16,"ops":1837.7,"usec":544.2},
|
||||
{"base":8,"power":3,"size":512,"exp2":9,"generator":"array_nest_fixnum","operation":"insert","iterations":2461,"utime":9.29,"etime":1.07,"rtime":10.3,"ops":264.9,"usec":3774.9},
|
||||
{"base":8,"power":4,"size":4096,"exp2":12,"generator":"array_nest_fixnum","operation":"insert","iterations":307,"utime":9.05,"etime":0.36,"rtime":16.31,"ops":33.9,"usec":29478.8},
|
||||
{"base":16,"power":0,"size":1,"exp2":0,"generator":"array_nest_fixnum","operation":"insert","iterations":146285,"utime":10.01,"etime":0.35,"rtime":23.91,"ops":14613.9,"usec":68.4},
|
||||
{"base":16,"power":1,"size":16,"exp2":4,"generator":"array_nest_fixnum","operation":"insert","iterations":56888,"utime":10.16,"etime":4.5,"rtime":13.81,"ops":5599.2,"usec":178.6},
|
||||
{"base":16,"power":2,"size":256,"exp2":8,"generator":"array_nest_fixnum","operation":"insert","iterations":5818,"utime":10.7,"etime":3.19,"rtime":12.46,"ops":543.7,"usec":1839.1},
|
||||
{"base":16,"power":3,"size":4096,"exp2":12,"generator":"array_nest_fixnum","operation":"insert","iterations":333,"utime":9.16,"etime":0.87,"rtime":10.1,"ops":36.4,"usec":27507.5},
|
||||
{"base":32,"power":0,"size":1,"exp2":0,"generator":"array_nest_fixnum","operation":"insert","iterations":146285,"utime":10.0,"etime":0.36,"rtime":13.3,"ops":14628.5,"usec":68.4},
|
||||
{"base":32,"power":1,"size":32,"exp2":5,"generator":"array_nest_fixnum","operation":"insert","iterations":34133,"utime":9.68,"etime":4.38,"rtime":11.39,"ops":3526.1,"usec":283.6},
|
||||
{"base":32,"power":2,"size":1024,"exp2":10,"generator":"array_nest_fixnum","operation":"insert","iterations":1454,"utime":9.97,"etime":2.79,"rtime":11.19,"ops":145.8,"usec":6856.9},
|
||||
{"base":2,"power":0,"size":1,"exp2":0,"generator":"hash_nest_fixnum","operation":"insert","iterations":136533,"utime":9.36,"etime":0.38,"rtime":12.73,"ops":14586.9,"usec":68.6},
|
||||
{"base":2,"power":1,"size":2,"exp2":1,"generator":"hash_nest_fixnum","operation":"insert","iterations":146285,"utime":10.0,"etime":16.55,"rtime":18.64,"ops":14628.5,"usec":68.4},
|
||||
{"base":2,"power":2,"size":4,"exp2":2,"generator":"hash_nest_fixnum","operation":"insert","iterations":157538,"utime":11.07,"etime":26.68,"rtime":24.48,"ops":14231.1,"usec":70.3},
|
||||
{"base":2,"power":3,"size":8,"exp2":3,"generator":"hash_nest_fixnum","operation":"insert","iterations":136533,"utime":10.14,"etime":7.95,"rtime":28.13,"ops":13464.8,"usec":74.3},
|
||||
{"base":2,"power":4,"size":16,"exp2":4,"generator":"hash_nest_fixnum","operation":"insert","iterations":113777,"utime":9.46,"etime":15.98,"rtime":12.98,"ops":12027.2,"usec":83.1},
|
||||
{"base":2,"power":5,"size":32,"exp2":5,"generator":"hash_nest_fixnum","operation":"insert","iterations":102399,"utime":9.72,"etime":4.09,"rtime":52.38,"ops":10534.9,"usec":94.9},
|
||||
{"base":2,"power":6,"size":64,"exp2":6,"generator":"hash_nest_fixnum","operation":"insert","iterations":78769,"utime":9.84,"etime":5.54,"rtime":60.71,"ops":8005.0,"usec":124.9},
|
||||
{"base":2,"power":7,"size":128,"exp2":7,"generator":"hash_nest_fixnum","operation":"insert","iterations":60235,"utime":10.36,"etime":11.54,"rtime":78.88,"ops":5814.2,"usec":172.0},
|
||||
{"base":2,"power":8,"size":256,"exp2":8,"generator":"hash_nest_fixnum","operation":"insert","iterations":36571,"utime":10.18,"etime":7.21,"rtime":21.93,"ops":3592.4,"usec":278.4},
|
||||
{"base":2,"power":9,"size":512,"exp2":9,"generator":"hash_nest_fixnum","operation":"insert","iterations":19692,"utime":9.78,"etime":106.23,"rtime":43.84,"ops":2013.5,"usec":496.6},
|
||||
{"base":2,"power":10,"size":1024,"exp2":10,"generator":"hash_nest_fixnum","operation":"insert","iterations":10666,"utime":9.86,"etime":3.1,"rtime":14.52,"ops":1081.7,"usec":924.4},
|
||||
{"base":2,"power":11,"size":2048,"exp2":11,"generator":"hash_nest_fixnum","operation":"insert","iterations":5333,"utime":9.68,"etime":71.52,"rtime":42.08,"ops":550.9,"usec":1815.1},
|
||||
{"base":2,"power":12,"size":4096,"exp2":12,"generator":"hash_nest_fixnum","operation":"insert","iterations":2285,"utime":10.0,"etime":1.78,"rtime":13.67,"ops":228.5,"usec":4376.4},
|
||||
{"base":2,"power":13,"size":8192,"exp2":13,"generator":"hash_nest_fixnum","operation":"insert","iterations":1000,"utime":9.6,"etime":0.64,"rtime":11.58,"ops":104.2,"usec":9600.0},
|
||||
{"base":2,"power":14,"size":16384,"exp2":14,"generator":"hash_nest_fixnum","operation":"insert","iterations":421,"utime":9.54,"etime":0.54,"rtime":35.17,"ops":44.1,"usec":22660.3},
|
||||
{"base":2,"power":15,"size":32768,"exp2":15,"generator":"hash_nest_fixnum","operation":"insert","iterations":181,"utime":7.96,"etime":0.59,"rtime":9.8,"ops":22.7,"usec":43977.9},
|
||||
{"base":4,"power":0,"size":1,"exp2":0,"generator":"hash_nest_fixnum","operation":"insert","iterations":157538,"utime":10.8,"etime":0.34,"rtime":43.16,"ops":14586.9,"usec":68.6},
|
||||
{"base":4,"power":1,"size":4,"exp2":2,"generator":"hash_nest_fixnum","operation":"insert","iterations":146285,"utime":10.39,"etime":8.4,"rtime":31.91,"ops":14079.4,"usec":71.0},
|
||||
{"base":4,"power":2,"size":16,"exp2":4,"generator":"hash_nest_fixnum","operation":"insert","iterations":127999,"utime":9.68,"etime":24.6,"rtime":46.3,"ops":13223.0,"usec":75.6},
|
||||
{"base":4,"power":3,"size":64,"exp2":6,"generator":"hash_nest_fixnum","operation":"insert","iterations":93090,"utime":9.23,"etime":18.63,"rtime":27.41,"ops":10085.6,"usec":99.2},
|
||||
{"base":4,"power":4,"size":256,"exp2":8,"generator":"hash_nest_fixnum","operation":"insert","iterations":56888,"utime":10.28,"etime":25.97,"rtime":26.29,"ops":5533.9,"usec":180.7},
|
||||
{"base":4,"power":5,"size":1024,"exp2":10,"generator":"hash_nest_fixnum","operation":"insert","iterations":21333,"utime":10.67,"etime":144.94,"rtime":161.78,"ops":1999.3,"usec":500.2},
|
||||
{"base":4,"power":6,"size":4096,"exp2":12,"generator":"hash_nest_fixnum","operation":"insert","iterations":5333,"utime":10.25,"etime":3.53,"rtime":12.63,"ops":520.3,"usec":1922.0},
|
||||
{"base":4,"power":7,"size":16384,"exp2":14,"generator":"hash_nest_fixnum","operation":"insert","iterations":1142,"utime":10.43,"etime":0.74,"rtime":12.8,"ops":109.5,"usec":9133.1},
|
||||
{"base":4,"power":8,"size":65536,"exp2":16,"generator":"hash_nest_fixnum","operation":"insert","iterations":142,"utime":10.86,"etime":0.25,"rtime":12.17,"ops":13.1,"usec":76478.9},
|
||||
{"base":8,"power":0,"size":1,"exp2":0,"generator":"hash_nest_fixnum","operation":"insert","iterations":146285,"utime":9.85,"etime":0.42,"rtime":90.49,"ops":14851.3,"usec":67.3},
|
||||
{"base":8,"power":1,"size":8,"exp2":3,"generator":"hash_nest_fixnum","operation":"insert","iterations":136533,"utime":9.57,"etime":52.26,"rtime":25.46,"ops":14266.8,"usec":70.1},
|
||||
{"base":8,"power":2,"size":64,"exp2":6,"generator":"hash_nest_fixnum","operation":"insert","iterations":113777,"utime":10.3,"etime":8.6,"rtime":152.42,"ops":11046.3,"usec":90.5},
|
||||
{"base":8,"power":3,"size":512,"exp2":9,"generator":"hash_nest_fixnum","operation":"insert","iterations":42666,"utime":9.97,"etime":18.08,"rtime":148.86,"ops":4279.4,"usec":233.7},
|
||||
{"base":8,"power":4,"size":4096,"exp2":12,"generator":"hash_nest_fixnum","operation":"insert","iterations":7111,"utime":9.75,"etime":103.25,"rtime":59.03,"ops":729.3,"usec":1371.1},
|
||||
{"base":16,"power":0,"size":1,"exp2":0,"generator":"hash_nest_fixnum","operation":"insert","iterations":157538,"utime":10.71,"etime":1.81,"rtime":47.49,"ops":14709.4,"usec":68.0},
|
||||
{"base":16,"power":1,"size":16,"exp2":4,"generator":"hash_nest_fixnum","operation":"insert","iterations":146285,"utime":10.6,"etime":16.1,"rtime":147.91,"ops":13800.5,"usec":72.5},
|
||||
{"base":16,"power":2,"size":256,"exp2":8,"generator":"hash_nest_fixnum","operation":"insert","iterations":60235,"utime":8.85,"etime":61.27,"rtime":184.66,"ops":6806.2,"usec":146.9},
|
||||
{"base":16,"power":3,"size":4096,"exp2":12,"generator":"hash_nest_fixnum","operation":"insert","iterations":7999,"utime":10.33,"etime":9.2,"rtime":13.69,"ops":774.3,"usec":1291.4},
|
||||
{"base":16,"power":4,"size":65536,"exp2":16,"generator":"hash_nest_fixnum","operation":"insert","iterations":333,"utime":9.39,"etime":1.44,"rtime":11.26,"ops":35.5,"usec":28198.2},
|
||||
{"base":32,"power":0,"size":1,"exp2":0,"generator":"hash_nest_fixnum","operation":"insert","iterations":146285,"utime":9.95,"etime":0.45,"rtime":199.41,"ops":14702.0,"usec":68.0},
|
||||
{"base":32,"power":1,"size":32,"exp2":5,"generator":"hash_nest_fixnum","operation":"insert","iterations":136533,"utime":10.55,"etime":26.98,"rtime":45.46,"ops":12941.5,"usec":77.3},
|
||||
{"base":32,"power":2,"size":1024,"exp2":10,"generator":"hash_nest_fixnum","operation":"insert","iterations":30117,"utime":10.42,"etime":173.43,"rtime":247.61,"ops":2890.3,"usec":346.0},
|
||||
{"base":32,"power":3,"size":32768,"exp2":15,"generator":"hash_nest_fixnum","operation":"insert","iterations":941,"utime":10.9,"etime":5.7,"rtime":18.17,"ops":86.3,"usec":11583.4}];
|
|
@ -0,0 +1,239 @@
|
|||
#!/usr/bin/env ruby
|
||||
$LOAD_PATH[0, 0] = File.join(File.dirname(__FILE__), '..', 'lib')
|
||||
#
|
||||
# review load path
|
||||
|
||||
# Exploratory/Experimental/Exponential tests for performance tuning
|
||||
|
||||
require 'rubygems'
|
||||
require 'test-unit'
|
||||
require 'json'
|
||||
require 'mongo'
|
||||
require 'benchmark'
|
||||
|
||||
$calibration_runtime = 0.1
|
||||
$target_runtime = 5.0
|
||||
$db_name = "benchmark"
|
||||
$collection_name = "exp_series"
|
||||
|
||||
class TestExpPerformance < Test::Unit::TestCase
|
||||
|
||||
def array_nest(base, level, obj)
|
||||
return obj if level == 0
|
||||
return Array.new(base, array_nest(base, level - 1, obj))
|
||||
end
|
||||
|
||||
def hash_nest(base, level, obj)
|
||||
return obj if level == 0
|
||||
h = Hash.new
|
||||
(0...base).each{|i| h[i.to_s] = hash_nest(base, level - 1, obj)}
|
||||
return h
|
||||
end
|
||||
|
||||
def estimate_iterations(db, coll, setup, teardown)
|
||||
start_time = Time.now
|
||||
iterations = 1
|
||||
utime = 0.0
|
||||
while utime <= $calibration_runtime do
|
||||
setup.call(db, coll)
|
||||
btms = Benchmark.measure do
|
||||
(0...iterations).each do
|
||||
yield
|
||||
end
|
||||
end
|
||||
utime = btms.utime
|
||||
teardown.call(db, coll)
|
||||
iterations *= 2
|
||||
end
|
||||
etime = (Time.now - start_time)
|
||||
return [(iterations.to_f * $target_runtime / utime).to_i, etime]
|
||||
end
|
||||
|
||||
def measure_iterations(db, coll, setup, teardown, iterations)
|
||||
setup.call(db, coll)
|
||||
btms = Benchmark.measure { iterations.times { yield } }
|
||||
teardown.call(db, coll)
|
||||
return [btms.utime, btms.real]
|
||||
end
|
||||
|
||||
def valuate(db, coll, setup, teardown)
|
||||
iterations, etime = estimate_iterations(db, coll, setup, teardown) { yield }
|
||||
utime, rtime = measure_iterations(db, coll, setup, teardown, iterations) { yield }
|
||||
return [iterations, utime, rtime, etime]
|
||||
end
|
||||
|
||||
def power_test(base, max_power, db, coll, generator, setup, operation, teardown)
|
||||
return (0..max_power).collect do |power|
|
||||
size, doc = generator.call(base, power)
|
||||
iterations, utime, rtime, etime = valuate(db, coll, setup, teardown) { operation.call(coll, doc) }
|
||||
result = {
|
||||
"base" => base,
|
||||
"power" => power,
|
||||
"size" => size,
|
||||
"exp2" => Math.log2(size).to_i,
|
||||
"generator" => generator.name.to_s,
|
||||
"operation" => operation.name.to_s,
|
||||
"iterations" => iterations,
|
||||
"utime" => utime.round(2),
|
||||
"etime" => etime.round(2),
|
||||
"rtime" => rtime.round(2),
|
||||
"ops" => (iterations.to_f / utime.to_f).round(1),
|
||||
"usec" => (1000000.0 * utime.to_f / iterations.to_f).round(1),
|
||||
# "git" => git, # thinking
|
||||
# "datetime" +> Time.now, # thinking
|
||||
# "hostname" => hostname, # thinking
|
||||
# "nbench-int" => nbench.int, # thinking
|
||||
}
|
||||
STDERR.puts result.inspect
|
||||
STDERR.flush
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
def value_string_size(base, power)
|
||||
n = base ** power
|
||||
return [n, {n.to_s => ("*" * n)}]
|
||||
end
|
||||
|
||||
def key_string_size(base, power)
|
||||
n = base ** power
|
||||
return [n, {("*" * n) => n}]
|
||||
end
|
||||
|
||||
def hash_size_fixnum(base, power)
|
||||
n = base ** power
|
||||
h = Hash.new
|
||||
(0...n).each { |i| h[i.to_s] = i }
|
||||
return [n, h]
|
||||
end
|
||||
|
||||
def array_size_fixnum(base, power)
|
||||
n = base ** power
|
||||
return [n, {n.to_s => Array.new(n, n)}]
|
||||
end
|
||||
|
||||
def array_nest_fixnum(base, power)
|
||||
n = base ** power
|
||||
return [n, {n.to_s => array_nest(base, power, n)}]
|
||||
end
|
||||
|
||||
def hash_nest_fixnum(base, power)
|
||||
n = base ** power
|
||||
return [n, {n.to_s => hash_nest(base, power, n)}]
|
||||
end
|
||||
|
||||
def null_setup(db, coll)
|
||||
|
||||
end
|
||||
|
||||
def insert(coll, h)
|
||||
h.delete(:_id) # delete :_id to insert
|
||||
coll.insert(h) # note that insert stores :_id in h and subsequent inserts are updates
|
||||
end
|
||||
|
||||
def default_teardown(db, coll)
|
||||
coll.remove
|
||||
#cmd = Hash.new.store('compact', $collection_name)
|
||||
#db.command(cmd)
|
||||
end
|
||||
|
||||
def test_array_nest
|
||||
assert_equal(1, array_nest(2,0,1))
|
||||
assert_equal([1, 1], array_nest(2,1,1))
|
||||
assert_equal([[1, 1], [1, 1]], array_nest(2,2,1))
|
||||
assert_equal([[[1, 1], [1, 1]], [[1, 1], [1, 1]]], array_nest(2,3,1))
|
||||
assert_equal(1, array_nest(4,0,1))
|
||||
assert_equal([1, 1, 1, 1], array_nest(4,1,1))
|
||||
assert_equal([[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]], array_nest(4,2,1))
|
||||
assert_equal(1, array_nest(8,0,1))
|
||||
assert_equal([1, 1, 1, 1, 1, 1, 1, 1], array_nest(8,1,1))
|
||||
end
|
||||
|
||||
def test_hash_nest # incomplete
|
||||
assert_equal(1, hash_nest(2, 0, 1))
|
||||
assert_equal({"0"=>1, "1"=>1}, hash_nest(2, 1, 1))
|
||||
assert_equal({"0"=>{"0"=>1, "1"=>1}, "1"=>{"0"=>1, "1"=>1}}, hash_nest(2, 2, 1))
|
||||
assert_equal({"0"=>{"0"=>{"0"=>1, "1"=>1}, "1"=>{"0"=>1, "1"=>1}},
|
||||
"1"=>{"0"=>{"0"=>1, "1"=>1}, "1"=>{"0"=>1, "1"=>1}}}, hash_nest(2, 3, 1))
|
||||
assert_equal(1, hash_nest(4,0,1))
|
||||
assert_equal({"0"=>1, "1"=>1, "2"=>1, "3"=>1}, hash_nest(4,1,1))
|
||||
assert_equal({"0"=>{"0"=>1, "1"=>1, "2"=>1, "3"=>1},
|
||||
"1"=>{"0"=>1, "1"=>1, "2"=>1, "3"=>1},
|
||||
"2"=>{"0"=>1, "1"=>1, "2"=>1, "3"=>1},
|
||||
"3"=>{"0"=>1, "1"=>1, "2"=>1, "3"=>1}}, hash_nest(4,2,1))
|
||||
assert_equal(1, hash_nest(8,0,1))
|
||||
assert_equal({"0"=>1, "1"=>1, "2"=>1, "3"=>1, "4"=>1, "5"=>1, "6"=>1, "7"=>1}, hash_nest(8,1,1))
|
||||
end
|
||||
|
||||
# Performance Tuning Engineering
|
||||
## Overall Strategy
|
||||
### Prioritize/Review Ruby 1.9.3, Ruby 1.8.7, JRuby 1.6.7
|
||||
### Run spectrum of exploratory performance tests
|
||||
### Graph results, probably with gnuplot, with HTML wrapper
|
||||
### Select test for profiling
|
||||
### Find where time is being spent
|
||||
### Construct specific performance test
|
||||
### Iteratively tune specific performance test
|
||||
### Iterate selection of test for profiling
|
||||
## Notes
|
||||
### Start with Create/insert, writing comes first
|
||||
### Then Read/find, reading comes next. both findOne and find-cursor
|
||||
### Update is primarily server load with minimal driver load for conditions
|
||||
### Delete/remove is primarily server load with minimal driver load for conditions
|
||||
## Benefits
|
||||
### Performance Improvements
|
||||
### Knowledge of Ruby driver and techniques
|
||||
### Perhaps architecture and design improvements
|
||||
### Lessons transferable to other drivers
|
||||
|
||||
def test_zzz_exp_blanket
|
||||
puts
|
||||
conn = Mongo::Connection.new
|
||||
conn.drop_database($db_name)
|
||||
db = conn.db($db_name)
|
||||
coll = db.collection($collection_name)
|
||||
coll.remove
|
||||
|
||||
tests = [
|
||||
# Create/insert
|
||||
[2, 15, :value_string_size, :null_setup, :insert, :default_teardown],
|
||||
[2, 15, :key_string_size, :null_setup, :insert, :default_teardown],
|
||||
[2, 14, :array_size_fixnum, :null_setup, :insert, :default_teardown],
|
||||
[2, 17, :hash_size_fixnum, :null_setup, :insert, :default_teardown],
|
||||
[2, 12, :array_nest_fixnum, :null_setup, :insert, :default_teardown],
|
||||
[4, 6, :array_nest_fixnum, :null_setup, :insert, :default_teardown],
|
||||
[8, 4, :array_nest_fixnum, :null_setup, :insert, :default_teardown],
|
||||
[16, 3, :array_nest_fixnum, :null_setup, :insert, :default_teardown],
|
||||
[32, 2, :array_nest_fixnum, :null_setup, :insert, :default_teardown],
|
||||
[2, 15, :hash_nest_fixnum, :null_setup, :insert, :default_teardown ],
|
||||
[4, 8, :hash_nest_fixnum, :null_setup, :insert, :default_teardown ],
|
||||
[8, 4, :hash_nest_fixnum, :null_setup, :insert, :default_teardown ],
|
||||
[16, 4, :hash_nest_fixnum, :null_setup, :insert, :default_teardown ],
|
||||
[32, 3, :hash_nest_fixnum, :null_setup, :insert, :default_teardown ],
|
||||
|
||||
# synthesized mix, real-world data pending
|
||||
|
||||
# Read/findOne/find pending
|
||||
|
||||
# Update pending
|
||||
|
||||
# Delete/remove pending
|
||||
|
||||
]
|
||||
results = []
|
||||
tests.each do |base, max_power, generator, setup, operation, teardown|
|
||||
# consider moving "method" as permitted by scope
|
||||
results += power_test(base, max_power, db, coll, method(generator), method(setup), method(operation), method(teardown))
|
||||
end
|
||||
# consider inserting the results into a database collection
|
||||
# Test::Unit::TestCase pollutes STDOUT, so write to a file
|
||||
File.open("exp_series.js", "w"){|f|
|
||||
f.puts("expSeries = #{results.to_json.gsub(/(\[|},)/, "\\1\n")};")
|
||||
}
|
||||
|
||||
conn.drop_database($db_name)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/env ruby
|
||||
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
|
||||
#
|
||||
# Note: Ruby 1.9 is faster than 1.8, as expected.
|
||||
# This suite will be run against the installed version of ruby-mongo-driver.
|
||||
# The c-extension, bson_ext, will be used if installed.
|
||||
|
||||
require 'rubygems'
|
||||
require 'mongo'
|
||||
require 'benchmark'
|
||||
require 'ruby-prof'
|
||||
|
||||
def array_size_fixnum(base, power)
|
||||
n = base ** power
|
||||
return [n, {n.to_s => Array.new(n, n)}]
|
||||
end
|
||||
|
||||
def array_size_fixnum(base, power)
|
||||
n = base ** power
|
||||
return [n, {n.to_s => Array.new(n, n)}]
|
||||
end
|
||||
|
||||
def insert(coll, h)
|
||||
h.delete(:_id) # delete :_id to insert
|
||||
coll.insert(h) # note that insert stores :_id in h and subsequent inserts are updates
|
||||
end
|
||||
|
||||
def profile(iterations)
|
||||
RubyProf.start
|
||||
puts Benchmark.measure {
|
||||
iterations.times { yield }
|
||||
}
|
||||
result = RubyProf.stop
|
||||
|
||||
# Print a flat profile to text
|
||||
printer = RubyProf::FlatPrinter.new(result)
|
||||
printer.print(STDOUT)
|
||||
|
||||
# Print a graph profile to text
|
||||
printer = RubyProf::GraphPrinter.new(result)
|
||||
printer.print(STDOUT, {})
|
||||
end
|
||||
|
||||
conn = Mongo::Connection.new
|
||||
|
||||
db = conn['benchmark']
|
||||
coll = db['profile']
|
||||
|
||||
coll.remove
|
||||
puts "coll.count: #{coll.count}"
|
||||
|
||||
n, doc = array_size_fixnum(2, 6)
|
||||
profile(1000) { insert(coll, doc) }
|
||||
|
||||
puts "coll.count: #{coll.count}"
|
||||
coll.remove
|
||||
|
Loading…
Reference in New Issue