Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

performance graphing and profiling improvements

  • Loading branch information...
commit 6f2b7624cf0efe87fb7ea0a2570e90987dafd781 1 parent 4c717f0
@gjmurakami-10gen gjmurakami-10gen authored
View
1  Gemfile
@@ -17,6 +17,7 @@ group :development, :test do
gem "ci_reporter"
gem "ruby-prof" unless RUBY_PLATFORM =~ /java/
gem "perftools.rb" unless RUBY_PLATFORM =~ /java/
+ gem "rake-compiler"
# Java
platforms :jruby do
View
10 Rakefile
@@ -7,6 +7,8 @@ end
require 'fileutils'
require 'rake/testtask'
require 'rake'
+require 'rake/extensiontask'
+require 'rake/javaextensiontask'
begin
require 'git'
@@ -20,6 +22,14 @@ end
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
Rake::Task['build:java'].invoke
Rake::Task['test:ruby'].invoke
View
8 bench/exp_series.html
@@ -25,7 +25,7 @@
<h1>Exp Series Performance Tests</h1>
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 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>
<script type="text/javascript">
@@ -136,10 +136,8 @@
]
];
$.each(graph, function(i, e){
- var title = e[0];
- var xMax = e[1];
- var labelSpec = e[2];
- var plotSpecs = e[3];
+ var title, xMax, labelSpec, plotSpecs;
+ title = e[0]; xMax = e[1]; labelSpec = e[2]; plotSpecs = e[3]; //[title, xMax, labelSpec, plotSpecs] = e;
var series = flotSeries(expSeries, xMax, labelSpec, plotSpecs);
doPlot(title, series);
});
View
26 bench/profile_array.rb
@@ -16,7 +16,6 @@ def set_mongo_driver_mode(mode)
end
$mode = ARGV[0].to_sym if ARGV[0]
-#p (ARGV[0] && ARGV[0].to_sym || :c)
set_mongo_driver_mode($mode || :c)
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
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)
RubyProf.start
puts Benchmark.measure {
@@ -57,7 +66,7 @@ def ruby_prof(iterations)
end
def perftools(iterations)
- profile_file_name = "/tmp/profile_array.perftools"
+ profile_file_name = '/tmp/profile_array.perftools'
PerfTools::CpuProfiler.start(profile_file_name) do
iterations.times { yield }
end
@@ -71,12 +80,17 @@ def perftools(iterations)
coll = db['profile']
coll.remove
-puts "coll.count: #{coll.count}"
+#puts "coll.count: #{coll.count}"
+
+base = 2
+power = 6
+n, doc = array_size_fixnum(base, power)
+p ({'generator' => 'array_size_fixnum', 'operation' => 'insert', 'base' => base, 'power' => power})
-n, doc = array_size_fixnum(2, 6)
-ruby_prof(1000) { insert(coll, doc) }
+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) }
-puts "coll.count: #{coll.count}"
+#puts "coll.count: #{coll.count}"
coll.remove
Please sign in to comment.
Something went wrong with that request. Please try again.