performance graphing and profiling improvements
This commit is contained in:
parent
4c717f0873
commit
6f2b7624cf
1
Gemfile
1
Gemfile
|
@ -17,6 +17,7 @@ group :development, :test do
|
||||||
gem "ci_reporter"
|
gem "ci_reporter"
|
||||||
gem "ruby-prof" unless RUBY_PLATFORM =~ /java/
|
gem "ruby-prof" unless RUBY_PLATFORM =~ /java/
|
||||||
gem "perftools.rb" unless RUBY_PLATFORM =~ /java/
|
gem "perftools.rb" unless RUBY_PLATFORM =~ /java/
|
||||||
|
gem "rake-compiler"
|
||||||
|
|
||||||
# Java
|
# Java
|
||||||
platforms :jruby do
|
platforms :jruby do
|
||||||
|
|
10
Rakefile
10
Rakefile
|
@ -7,6 +7,8 @@ end
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
require 'rake/testtask'
|
require 'rake/testtask'
|
||||||
require 'rake'
|
require 'rake'
|
||||||
|
require 'rake/extensiontask'
|
||||||
|
require 'rake/javaextensiontask'
|
||||||
|
|
||||||
begin
|
begin
|
||||||
require 'git'
|
require 'git'
|
||||||
|
@ -20,6 +22,14 @@ end
|
||||||
|
|
||||||
ENV['TEST_MODE'] = 'TRUE'
|
ENV['TEST_MODE'] = 'TRUE'
|
||||||
|
|
||||||
|
Rake::ExtensionTask.new('cbson') do |ext|
|
||||||
|
ext.lib_dir = "lib/bson_ext"
|
||||||
|
end
|
||||||
|
|
||||||
|
#Rake::JavaExtensionTask.new('jbson') do |ext| # not yet functional
|
||||||
|
# ext.ext_dir = 'ext/src/org/jbson'
|
||||||
|
#end
|
||||||
|
|
||||||
task :java do
|
task :java do
|
||||||
Rake::Task['build:java'].invoke
|
Rake::Task['build:java'].invoke
|
||||||
Rake::Task['test:ruby'].invoke
|
Rake::Task['test:ruby'].invoke
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
<h1>Exp Series Performance Tests</h1>
|
<h1>Exp Series Performance Tests</h1>
|
||||||
x-axis is power of 2, log base 2 of size<br>
|
x-axis is power of 2, log base 2 of size<br>
|
||||||
y-axis is operations per user-time CPU-second<br>
|
y-axis is operations per user-time CPU-second<br>
|
||||||
Note that this is not operations per real-time second that includes DB real-time<br>
|
Note that this is not operations per real-time second that include DB real-time<br>
|
||||||
<div id="placeholder"></div>
|
<div id="placeholder"></div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
@ -136,10 +136,8 @@ $(function () {
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
$.each(graph, function(i, e){
|
$.each(graph, function(i, e){
|
||||||
var title = e[0];
|
var title, xMax, labelSpec, plotSpecs;
|
||||||
var xMax = e[1];
|
title = e[0]; xMax = e[1]; labelSpec = e[2]; plotSpecs = e[3]; //[title, xMax, labelSpec, plotSpecs] = e;
|
||||||
var labelSpec = e[2];
|
|
||||||
var plotSpecs = e[3];
|
|
||||||
var series = flotSeries(expSeries, xMax, labelSpec, plotSpecs);
|
var series = flotSeries(expSeries, xMax, labelSpec, plotSpecs);
|
||||||
doPlot(title, series);
|
doPlot(title, series);
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,7 +16,6 @@ def set_mongo_driver_mode(mode)
|
||||||
end
|
end
|
||||||
|
|
||||||
$mode = ARGV[0].to_sym if ARGV[0]
|
$mode = ARGV[0].to_sym if ARGV[0]
|
||||||
#p (ARGV[0] && ARGV[0].to_sym || :c)
|
|
||||||
set_mongo_driver_mode($mode || :c)
|
set_mongo_driver_mode($mode || :c)
|
||||||
|
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
|
@ -40,6 +39,16 @@ def insert(coll, h)
|
||||||
coll.insert(h) # note that insert stores :_id in h and subsequent inserts are updates
|
coll.insert(h) # note that insert stores :_id in h and subsequent inserts are updates
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def benchmark(iterations)
|
||||||
|
btms = Benchmark.measure do
|
||||||
|
(0...iterations).each do
|
||||||
|
yield
|
||||||
|
end
|
||||||
|
end
|
||||||
|
utime = btms.utime
|
||||||
|
p ({'ops' => (iterations.to_f / utime.to_f).round(1)})
|
||||||
|
end
|
||||||
|
|
||||||
def ruby_prof(iterations)
|
def ruby_prof(iterations)
|
||||||
RubyProf.start
|
RubyProf.start
|
||||||
puts Benchmark.measure {
|
puts Benchmark.measure {
|
||||||
|
@ -57,7 +66,7 @@ def ruby_prof(iterations)
|
||||||
end
|
end
|
||||||
|
|
||||||
def perftools(iterations)
|
def perftools(iterations)
|
||||||
profile_file_name = "/tmp/profile_array.perftools"
|
profile_file_name = '/tmp/profile_array.perftools'
|
||||||
PerfTools::CpuProfiler.start(profile_file_name) do
|
PerfTools::CpuProfiler.start(profile_file_name) do
|
||||||
iterations.times { yield }
|
iterations.times { yield }
|
||||||
end
|
end
|
||||||
|
@ -71,12 +80,17 @@ db = conn['benchmark']
|
||||||
coll = db['profile']
|
coll = db['profile']
|
||||||
|
|
||||||
coll.remove
|
coll.remove
|
||||||
puts "coll.count: #{coll.count}"
|
#puts "coll.count: #{coll.count}"
|
||||||
|
|
||||||
n, doc = array_size_fixnum(2, 6)
|
base = 2
|
||||||
ruby_prof(1000) { insert(coll, doc) }
|
power = 6
|
||||||
|
n, doc = array_size_fixnum(base, power)
|
||||||
|
p ({'generator' => 'array_size_fixnum', 'operation' => 'insert', 'base' => base, 'power' => power})
|
||||||
|
|
||||||
|
benchmark(10000) { insert(coll, doc)} # valgrind --tool=callgrind ruby bench/profile_array.rb; callgrind_annotate ...
|
||||||
|
#ruby_prof(1000) { insert(coll, doc) }
|
||||||
#perftools(10000) { insert(coll, doc) }
|
#perftools(10000) { insert(coll, doc) }
|
||||||
|
|
||||||
puts "coll.count: #{coll.count}"
|
#puts "coll.count: #{coll.count}"
|
||||||
coll.remove
|
coll.remove
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue