2012-04-09 15:39:57 +00:00
|
|
|
#!/usr/bin/env ruby
|
2012-04-16 21:28:48 +00:00
|
|
|
$LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__))
|
|
|
|
|
2012-04-25 21:15:31 +00:00
|
|
|
require 'rubygems'
|
|
|
|
require 'getoptlong'
|
|
|
|
require 'json'
|
|
|
|
require 'benchmark'
|
|
|
|
require 'test-unit'
|
|
|
|
|
|
|
|
def set_mode(mode)
|
2012-04-16 21:28:48 +00:00
|
|
|
case mode
|
2012-04-25 21:15:31 +00:00
|
|
|
when 'c'
|
2012-04-16 21:28:48 +00:00
|
|
|
ENV.delete('TEST_MODE')
|
|
|
|
ENV['C_EXT'] = 'TRUE'
|
2012-04-25 21:15:31 +00:00
|
|
|
when 'ruby'
|
2012-04-16 21:28:48 +00:00
|
|
|
ENV['TEST_MODE'] = 'TRUE'
|
|
|
|
ENV.delete('C_EXT')
|
|
|
|
else
|
2012-04-25 21:15:31 +00:00
|
|
|
raise 'mode must be c or ruby'
|
2012-04-16 21:28:48 +00:00
|
|
|
end
|
2012-04-25 21:15:31 +00:00
|
|
|
return mode
|
2012-04-16 21:28:48 +00:00
|
|
|
end
|
|
|
|
|
2012-04-25 21:15:31 +00:00
|
|
|
$description = 'Exploratory/Experimental/Exponential tests for Ruby-driver performance tuning'
|
2012-05-11 19:19:38 +00:00
|
|
|
$calibration_runtime = 0.5
|
|
|
|
$target_runtime = 15.0
|
2012-04-16 21:28:48 +00:00
|
|
|
$db_name = 'benchmark'
|
|
|
|
$collection_name = 'exp_series'
|
2012-05-03 20:43:12 +00:00
|
|
|
$mode = set_mode('c')
|
2012-04-25 21:15:31 +00:00
|
|
|
$hostname = `uname -n`[/([^.]*)/,1]
|
|
|
|
$osname = `uname -s`.strip
|
|
|
|
$tag = `git log -1 --format=oneline`.split[0]
|
|
|
|
$date = Time.now.strftime('%Y%m%d-%H%M')
|
2012-05-11 19:19:38 +00:00
|
|
|
$file_name_opt = nil
|
2012-04-25 21:15:31 +00:00
|
|
|
|
|
|
|
options_with_help = [
|
|
|
|
[ '--help', '-h', GetoptLong::NO_ARGUMENT, '', 'show help' ],
|
2012-05-11 19:19:38 +00:00
|
|
|
[ '--file', '-f', GetoptLong::OPTIONAL_ARGUMENT, ' file', 'output file name' ],
|
2012-05-03 20:43:12 +00:00
|
|
|
[ '--mode', '-m', GetoptLong::OPTIONAL_ARGUMENT, ' mode', 'set mode to "c" or "ruby" (c)' ],
|
2012-04-25 21:15:31 +00:00
|
|
|
[ '--tag', '-t', GetoptLong::OPTIONAL_ARGUMENT, ' tag', 'set tag for run, default is git commit key' ]
|
|
|
|
]
|
|
|
|
options = options_with_help.collect{|option|option[0...3]}
|
2012-05-11 19:19:38 +00:00
|
|
|
|
2012-04-25 21:15:31 +00:00
|
|
|
GetoptLong.new(*options).each do |opt, arg|
|
|
|
|
case opt
|
|
|
|
when '--help'
|
2012-04-30 21:21:50 +00:00
|
|
|
puts "#{$0} -- #{$description}\n"
|
|
|
|
puts "usage: #{$0} [performance-options] [-- test-unit-options]"
|
2012-05-11 19:19:38 +00:00
|
|
|
puts "example: #{$0} --mode c --tag with-c-ext -- --verbose verbose --name test_insert"
|
2012-04-30 21:21:50 +00:00
|
|
|
puts "performance-options:"
|
2012-04-25 21:15:31 +00:00
|
|
|
options_with_help.each{|option| puts "#{option[0]}#{option[3]}, #{option[1]}#{option[3]}\n\t#{option[4]}"}
|
|
|
|
exit 0
|
2012-05-11 19:19:38 +00:00
|
|
|
when '--file'
|
|
|
|
$file_name_opt = arg
|
2012-04-25 21:15:31 +00:00
|
|
|
when '--mode'
|
|
|
|
$mode = set_mode(arg)
|
|
|
|
when '--tag'
|
|
|
|
$tag = arg
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-05-11 19:19:38 +00:00
|
|
|
$file_name = $file_name_opt ? $file_name_opt : "exp_series_#{$date}_#{$tag}_#{$mode}.js"
|
|
|
|
|
2012-04-25 21:15:31 +00:00
|
|
|
require 'mongo' # must be after option processing
|
2012-04-16 21:28:48 +00:00
|
|
|
|
|
|
|
class Hash
|
|
|
|
def store_embedded(key, value)
|
|
|
|
case key
|
|
|
|
when /([^.]*)\.(.*)/
|
|
|
|
store($1, Hash.new) unless fetch($1, nil)
|
|
|
|
self[$1].store_embedded($2, value)
|
|
|
|
else
|
|
|
|
store(key, value)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def sys_info
|
|
|
|
h = Hash.new
|
|
|
|
if FileTest.executable?('/usr/sbin/sysctl')
|
2012-05-04 21:16:57 +00:00
|
|
|
text = `/usr/sbin/sysctl -a kern.ostype kern.version kern.hostname hw.machine hw.model hw.cputype hw.cpusubtype hw.busfrequency hw.cpufrequency hw.memsize hw.physicalcpu hw.logicalcpu hw.packages`
|
2012-04-16 21:28:48 +00:00
|
|
|
values = text.split(/\n/).collect{|line| /([^:]*) *[:=] *(.*)/.match(line)[1..2]}
|
|
|
|
h = Hash.new
|
|
|
|
values.each{|key, value| h.store_embedded(key, value) }
|
|
|
|
end
|
|
|
|
return h
|
|
|
|
end
|
2012-04-09 15:39:57 +00:00
|
|
|
|
|
|
|
class TestExpPerformance < Test::Unit::TestCase
|
2012-04-30 21:21:50 +00:00
|
|
|
setup :setup_test_set
|
|
|
|
teardown :teardown_test_set
|
2012-04-09 15:39:57 +00:00
|
|
|
|
|
|
|
def array_nest(base, level, obj)
|
|
|
|
return obj if level == 0
|
|
|
|
return Array.new(base, array_nest(base, level - 1, obj))
|
|
|
|
end
|
|
|
|
|
2012-04-30 21:21:50 +00:00
|
|
|
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
|
|
|
|
|
2012-05-03 20:43:12 +00:00
|
|
|
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
|
|
|
|
|
2012-04-30 21:21:50 +00:00
|
|
|
def test__hash_nest
|
|
|
|
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
|
|
|
|
|
2012-05-03 20:43:12 +00:00
|
|
|
def multi_doc(multi_power, doc)
|
|
|
|
return doc if multi_power == -1
|
|
|
|
return (2 ** multi_power).times.collect{doc.dup}
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_multi_doc
|
|
|
|
doc = {'a' => 1}
|
|
|
|
assert_equal({"a"=>1}, multi_doc(-1, doc))
|
|
|
|
assert_equal([{"a"=>1}], multi_doc(0, doc))
|
|
|
|
assert_equal([{"a"=>1}, {"a"=>1}], multi_doc(1, doc))
|
|
|
|
assert_equal([{"a"=>1}, {"a"=>1}, {"a"=>1}, {"a"=>1}], multi_doc(2, doc))
|
|
|
|
assert_equal(8, multi_doc(3, doc).size)
|
|
|
|
assert_equal(16, multi_doc(4, doc).size)
|
|
|
|
assert_equal(32, multi_doc(5, doc).size)
|
|
|
|
mdoc = multi_doc(2, doc)
|
|
|
|
mdoc[0]['b'] = 2
|
|
|
|
assert_equal([{"a"=>1, "b"=>2}, {"a"=>1}, {"a"=>1}, {"a"=>1}], mdoc, 'non-dup doc will fail for insert many safe')
|
|
|
|
end
|
|
|
|
|
2012-04-30 21:21:50 +00:00
|
|
|
# Performance Tuning Engineering
|
|
|
|
## Completed
|
|
|
|
### How to measure and compare pure Ruby versus C extension performance
|
|
|
|
## Current Work Items
|
|
|
|
### Profiling of C extension
|
|
|
|
## Overall Strategy
|
|
|
|
### Prioritize/Review Ruby 1.9.3, JRuby 1.6.7, Ruby 1.8.7
|
|
|
|
### Run spectrum of exploratory performance tests
|
|
|
|
### Graph results with flot in HTML wrapper - http://code.google.com/p/flot/
|
|
|
|
### 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
|
|
|
|
## HW Info
|
|
|
|
### Linux - /proc/cpuinfo
|
|
|
|
### Mac OS X - sysctl -a hw
|
|
|
|
|
|
|
|
def setup_test_set
|
|
|
|
@conn = Mongo::Connection.new
|
|
|
|
@conn.drop_database($db_name)
|
|
|
|
@db = @conn.db($db_name)
|
|
|
|
@coll = @db.collection($collection_name)
|
|
|
|
@coll.remove
|
|
|
|
@results = []
|
|
|
|
puts
|
2012-05-04 21:16:57 +00:00
|
|
|
puts JSON.pretty_generate({'mode' => $mode , 'hostname' => $hostname, 'osname' => $osname, 'date' => $date, 'tag' => $tag})
|
|
|
|
puts JSON.pretty_generate(sys_info)
|
2012-04-30 21:21:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def teardown_test_set
|
|
|
|
# consider inserting the results into a database collection
|
|
|
|
# Test::Unit::TestCase pollutes STDOUT, so write to a file
|
2012-05-11 19:19:38 +00:00
|
|
|
File.open($file_name, 'a'){|f|
|
|
|
|
f.puts(@results.to_json.gsub(/\[/, "").gsub(/}[\],]/, "},\n")) if @results != []
|
2012-04-30 21:21:50 +00:00
|
|
|
}
|
|
|
|
@conn.drop_database($db_name)
|
|
|
|
end
|
|
|
|
|
2012-04-25 21:15:31 +00:00
|
|
|
def estimate_iterations(db, coll, doc, setup, teardown)
|
2012-04-09 15:39:57 +00:00
|
|
|
start_time = Time.now
|
|
|
|
iterations = 1
|
|
|
|
utime = 0.0
|
|
|
|
while utime <= $calibration_runtime do
|
2012-05-11 19:19:38 +00:00
|
|
|
iterations *= 2
|
2012-04-25 21:15:31 +00:00
|
|
|
setup.call(db, coll, doc, iterations)
|
2012-04-09 15:39:57 +00:00
|
|
|
btms = Benchmark.measure do
|
|
|
|
(0...iterations).each do
|
|
|
|
yield
|
|
|
|
end
|
|
|
|
end
|
|
|
|
utime = btms.utime
|
|
|
|
teardown.call(db, coll)
|
|
|
|
end
|
|
|
|
etime = (Time.now - start_time)
|
|
|
|
return [(iterations.to_f * $target_runtime / utime).to_i, etime]
|
|
|
|
end
|
|
|
|
|
2012-04-25 21:15:31 +00:00
|
|
|
def measure_iterations(db, coll, doc, setup, teardown, iterations)
|
|
|
|
setup.call(db, coll, doc, iterations)
|
2012-04-09 15:39:57 +00:00
|
|
|
btms = Benchmark.measure { iterations.times { yield } }
|
|
|
|
teardown.call(db, coll)
|
|
|
|
return [btms.utime, btms.real]
|
|
|
|
end
|
|
|
|
|
2012-04-25 21:15:31 +00:00
|
|
|
def valuate(db, coll, doc, setup, teardown)
|
2012-04-30 21:21:50 +00:00
|
|
|
@conn.drop_database($db_name) # hack to reduce paging
|
2012-04-25 21:15:31 +00:00
|
|
|
iterations, etime = estimate_iterations(db, coll, doc, setup, teardown) { yield }
|
2012-04-30 21:21:50 +00:00
|
|
|
@conn.drop_database($db_name) # hack to reduce paging
|
2012-04-25 21:15:31 +00:00
|
|
|
utime, rtime = measure_iterations(db, coll, doc, setup, teardown, iterations) { yield }
|
2012-04-09 15:39:57 +00:00
|
|
|
return [iterations, utime, rtime, etime]
|
|
|
|
end
|
|
|
|
|
2012-05-03 20:43:12 +00:00
|
|
|
def power_test(args)
|
2012-05-11 19:19:38 +00:00
|
|
|
base, power_enum, multi_enum, generator, setup, operation, teardown = args
|
2012-05-03 20:43:12 +00:00
|
|
|
generator, setup, operation, teardown = method(generator), method(setup), method(operation), method(teardown)
|
2012-05-11 19:19:38 +00:00
|
|
|
return power_enum.collect do |power|
|
|
|
|
multi_enum.collect do |multi_power|
|
|
|
|
status = 'OK'
|
2012-05-03 20:43:12 +00:00
|
|
|
size, doc = generator.call(base, power)
|
|
|
|
doc = multi_doc(multi_power, doc)
|
|
|
|
multi_size = (doc.class == Array) ? doc.size : 1;
|
2012-05-11 19:19:38 +00:00
|
|
|
iterations, utime, rtime, etime = begin
|
|
|
|
valuate(@db, @coll, doc, setup, teardown) { operation.call(@coll, doc) }
|
|
|
|
rescue Mongo::InvalidOperation => e
|
|
|
|
status = "#{e.class}: #{e.message}"
|
|
|
|
[0, 1.0, 1.0, 1.0]
|
|
|
|
end
|
2012-05-03 20:43:12 +00:00
|
|
|
multi_iterations = multi_size.to_f * iterations.to_f
|
2012-05-11 19:19:38 +00:00
|
|
|
user_ops = (multi_iterations / utime.to_f).round(1)
|
|
|
|
real_ops = (multi_iterations / rtime.to_f).round(1)
|
2012-05-03 20:43:12 +00:00
|
|
|
result = {
|
|
|
|
'base' => base,
|
|
|
|
'power' => power,
|
|
|
|
'size' => size,
|
|
|
|
'exp2' => Math.log2(size).to_i,
|
|
|
|
'multi_power' => multi_power,
|
|
|
|
'multi_size' => multi_size,
|
|
|
|
'generator' => generator.name.to_s,
|
|
|
|
'operation' => operation.name.to_s,
|
|
|
|
'iterations' => iterations,
|
2012-05-11 19:19:38 +00:00
|
|
|
'user_time' => utime.round(2),
|
|
|
|
'real_time' => rtime.round(2),
|
|
|
|
'user_ops' => user_ops.nan? ? 0 : user_ops,
|
|
|
|
'real_ops' => real_ops.nan? ? 0 : real_ops,
|
|
|
|
'user_usec' => (1000000.0 * utime.to_f / [multi_iterations, 1].max).round(1),
|
|
|
|
'real_usec' => (1000000.0 * rtime.to_f / [multi_iterations, 1].max).round(1),
|
|
|
|
'est_time' => etime.round(2),
|
2012-05-03 20:43:12 +00:00
|
|
|
'mode' => $mode,
|
|
|
|
'hostname' => $hostname,
|
|
|
|
'osname' => $osname,
|
|
|
|
'date' => $date,
|
|
|
|
'tag' => $tag,
|
2012-05-11 19:19:38 +00:00
|
|
|
'status' => status,
|
2012-05-03 20:43:12 +00:00
|
|
|
# 'nbench-int' => nbench.int, # thinking
|
|
|
|
}
|
2012-05-11 19:19:38 +00:00
|
|
|
STDERR.puts result.to_json #result.inspect
|
2012-05-03 20:43:12 +00:00
|
|
|
STDERR.flush
|
|
|
|
result
|
|
|
|
end
|
|
|
|
end.flatten
|
2012-04-09 15:39:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def value_string_size(base, power)
|
|
|
|
n = base ** power
|
2012-04-16 21:28:48 +00:00
|
|
|
return [n, {n.to_s => ('*' * n)}]
|
2012-04-09 15:39:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def key_string_size(base, power)
|
|
|
|
n = base ** power
|
2012-04-16 21:28:48 +00:00
|
|
|
return [n, {('*' * n) => n}]
|
2012-04-09 15:39:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def hash_size_fixnum(base, power)
|
|
|
|
n = base ** power
|
|
|
|
h = Hash.new
|
|
|
|
(0...n).each { |i| h[i.to_s] = i }
|
2012-04-16 21:28:48 +00:00
|
|
|
return [n, {n.to_s => h}] # embedded like array_size_fixnum
|
2012-04-09 15:39:57 +00:00
|
|
|
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
|
|
|
|
|
2012-04-25 21:15:31 +00:00
|
|
|
def null_setup(db, coll, doc, iterations)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2012-05-11 19:19:38 +00:00
|
|
|
def default_teardown(db, coll)
|
|
|
|
coll.remove
|
|
|
|
raise 'coll not removed' if coll.size > 0
|
2012-04-25 21:15:31 +00:00
|
|
|
end
|
2012-04-09 15:39:57 +00:00
|
|
|
|
2012-05-03 20:43:12 +00:00
|
|
|
def clear_ids(doc) # delete :_id to really insert, required for safe
|
|
|
|
if doc.class == Array
|
|
|
|
doc.each{|d|d.delete(:_id)}
|
|
|
|
else
|
|
|
|
doc.delete(:_id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-04-25 21:15:31 +00:00
|
|
|
def insert(coll, doc)
|
2012-05-03 20:43:12 +00:00
|
|
|
clear_ids(doc)
|
2012-04-25 21:15:31 +00:00
|
|
|
coll.insert(doc) # note that insert stores :_id in doc and subsequent inserts are updates
|
2012-04-09 15:39:57 +00:00
|
|
|
end
|
|
|
|
|
2012-04-30 21:21:50 +00:00
|
|
|
def insert_safe(coll, doc)
|
2012-05-03 20:43:12 +00:00
|
|
|
clear_ids(doc)
|
|
|
|
coll.insert(doc, :safe => true) # note that insert stores :_id in doc and subsequent inserts with :_id are updates
|
2012-04-25 21:15:31 +00:00
|
|
|
end
|
|
|
|
|
2012-05-11 19:19:38 +00:00
|
|
|
def find_one_setup(db, coll, doc, iterations)
|
|
|
|
insert(coll, doc)
|
2012-04-09 15:39:57 +00:00
|
|
|
end
|
|
|
|
|
2012-04-30 21:21:50 +00:00
|
|
|
def find_one(coll, doc)
|
|
|
|
h = coll.find_one
|
|
|
|
raise "find_one failed" unless h
|
2012-04-25 21:15:31 +00:00
|
|
|
end
|
|
|
|
|
2012-05-11 19:19:38 +00:00
|
|
|
def find_many_setup(db, coll, doc, iterations)
|
|
|
|
(0...(iterations - coll.size)).each{insert(coll, doc)} #TODO - insert many
|
|
|
|
@cursor = coll.find
|
|
|
|
@queries = 1
|
|
|
|
end
|
|
|
|
|
|
|
|
def find_many(coll, doc)
|
|
|
|
h = @cursor.next
|
|
|
|
unless h
|
|
|
|
@cursor = coll.find
|
|
|
|
@queries += 1
|
|
|
|
@cursor.next
|
|
|
|
end
|
2012-04-09 15:39:57 +00:00
|
|
|
end
|
|
|
|
|
2012-05-11 19:19:38 +00:00
|
|
|
def find_many_teardown(db, coll)
|
2012-04-30 21:21:50 +00:00
|
|
|
puts "queries: #{@queries}" if @queries > 1
|
|
|
|
default_teardown(db, coll)
|
2012-04-09 15:39:57 +00:00
|
|
|
end
|
|
|
|
|
2012-05-04 21:16:57 +00:00
|
|
|
def test_null
|
|
|
|
# just setup/teardown for options parsing and sys_info
|
|
|
|
end
|
|
|
|
|
2012-05-11 19:19:38 +00:00
|
|
|
def test_array_fast
|
2012-05-03 20:43:12 +00:00
|
|
|
[
|
2012-05-11 19:19:38 +00:00
|
|
|
[2, (0..14), (-1..-1), :array_size_fixnum, :null_setup, :insert, :default_teardown],
|
|
|
|
[2, (0..17), (-1..-1), :hash_size_fixnum, :null_setup, :insert, :default_teardown],
|
|
|
|
[2, (0..12), (-1..-1), :array_nest_fixnum, :null_setup, :insert, :default_teardown],
|
|
|
|
[2, (0..15), (-1..-1), :hash_nest_fixnum, :null_setup, :insert, :default_teardown],
|
2012-05-03 20:43:12 +00:00
|
|
|
].each{|args| @results += power_test(args)}
|
|
|
|
end
|
|
|
|
|
2012-05-11 19:19:38 +00:00
|
|
|
def test_insert_one
|
2012-05-03 20:43:12 +00:00
|
|
|
[
|
2012-05-11 19:19:38 +00:00
|
|
|
[2, (0..15), (-1..-1), :value_string_size, :null_setup, :insert, :default_teardown],
|
|
|
|
[2, (0..15), (-1..-1), :key_string_size, :null_setup, :insert, :default_teardown],
|
|
|
|
[2, (0..14), (-1..-1), :array_size_fixnum, :null_setup, :insert, :default_teardown],
|
|
|
|
[2, (0..17), (-1..-1), :hash_size_fixnum, :null_setup, :insert, :default_teardown],
|
|
|
|
[2, (0..12), (-1..-1), :array_nest_fixnum, :null_setup, :insert, :default_teardown],
|
|
|
|
[2, (0..15), (-1..-1), :hash_nest_fixnum, :null_setup, :insert, :default_teardown],
|
2012-05-03 20:43:12 +00:00
|
|
|
].each{|args| @results += power_test(args)}
|
|
|
|
end
|
|
|
|
|
2012-05-11 19:19:38 +00:00
|
|
|
def test_insert_one_safe
|
2012-05-03 20:43:12 +00:00
|
|
|
[
|
2012-05-11 19:19:38 +00:00
|
|
|
[2, (0..15), (-1..-1), :value_string_size, :null_setup, :insert_safe, :default_teardown],
|
|
|
|
[2, (0..15), (-1..-1), :key_string_size, :null_setup, :insert_safe, :default_teardown],
|
|
|
|
[2, (0..14), (-1..-1), :array_size_fixnum, :null_setup, :insert_safe, :default_teardown],
|
|
|
|
[2, (0..17), (-1..-1), :hash_size_fixnum, :null_setup, :insert_safe, :default_teardown],
|
|
|
|
[2, (0..12), (-1..-1), :array_nest_fixnum, :null_setup, :insert_safe, :default_teardown],
|
|
|
|
[2, (0..15), (-1..-1), :hash_nest_fixnum, :null_setup, :insert_safe, :default_teardown],
|
2012-05-03 20:43:12 +00:00
|
|
|
].each{|args| @results += power_test(args)}
|
2012-04-30 21:21:50 +00:00
|
|
|
end
|
2012-04-09 15:39:57 +00:00
|
|
|
|
2012-05-11 19:19:38 +00:00
|
|
|
def test_insert_many
|
|
|
|
sizes = [0, 2, 4, 6, 8, 10, 12]
|
|
|
|
multi = [0, 2, 4, 6, 8, 10, 12]
|
2012-05-03 20:43:12 +00:00
|
|
|
[
|
2012-05-11 19:19:38 +00:00
|
|
|
[2, sizes, multi, :value_string_size, :null_setup, :insert, :default_teardown],
|
|
|
|
[2, sizes, multi, :key_string_size, :null_setup, :insert, :default_teardown],
|
|
|
|
[2, sizes, multi, :hash_size_fixnum, :null_setup, :insert, :default_teardown],
|
|
|
|
[2, sizes, multi, :array_size_fixnum, :null_setup, :insert, :default_teardown],
|
|
|
|
[2, sizes, multi, :array_nest_fixnum, :null_setup, :insert, :default_teardown],
|
|
|
|
[2, sizes, multi, :hash_nest_fixnum, :null_setup, :insert, :default_teardown],
|
2012-05-03 20:43:12 +00:00
|
|
|
].each{|args| @results += power_test(args)}
|
2012-04-30 21:21:50 +00:00
|
|
|
end
|
2012-04-09 15:39:57 +00:00
|
|
|
|
2012-05-11 19:19:38 +00:00
|
|
|
def test_insert_many_safe
|
|
|
|
sizes = [0, 2, 4, 6, 8, 10, 12]
|
|
|
|
multi = [0, 2, 4, 6, 8, 10, 12]
|
2012-05-03 20:43:12 +00:00
|
|
|
[
|
2012-05-11 19:19:38 +00:00
|
|
|
[2, sizes, multi, :value_string_size, :null_setup, :insert_safe, :default_teardown],
|
|
|
|
[2, sizes, multi, :key_string_size, :null_setup, :insert_safe, :default_teardown],
|
|
|
|
[2, sizes, multi, :hash_size_fixnum, :null_setup, :insert_safe, :default_teardown],
|
|
|
|
[2, sizes, multi, :array_size_fixnum, :null_setup, :insert_safe, :default_teardown],
|
|
|
|
[2, sizes, multi, :array_nest_fixnum, :null_setup, :insert_safe, :default_teardown],
|
|
|
|
[2, sizes, multi, :hash_nest_fixnum, :null_setup, :insert_safe, :default_teardown],
|
2012-05-03 20:43:12 +00:00
|
|
|
].each{|args| @results += power_test(args)}
|
2012-04-30 21:21:50 +00:00
|
|
|
end
|
|
|
|
|
2012-05-11 19:19:38 +00:00
|
|
|
def test_find_one
|
2012-05-03 20:43:12 +00:00
|
|
|
[
|
2012-05-11 19:19:38 +00:00
|
|
|
[2, (0..15), (-1..-1), :value_string_size, :find_one_setup, :find_one, :default_teardown],
|
|
|
|
[2, (0..15), (-1..-1), :key_string_size, :find_one_setup, :find_one, :default_teardown],
|
|
|
|
[2, (0..14), (-1..-1), :array_size_fixnum, :find_one_setup, :find_one, :default_teardown],
|
|
|
|
[2, (0..17), (-1..-1), :hash_size_fixnum, :find_one_setup, :find_one, :default_teardown],
|
|
|
|
[2, (0..12), (-1..-1), :array_nest_fixnum, :find_one_setup, :find_one, :default_teardown],
|
|
|
|
[2, (0..15), (-1..-1), :hash_nest_fixnum, :find_one_setup, :find_one, :default_teardown],
|
2012-05-03 20:43:12 +00:00
|
|
|
].each{|args| @results += power_test(args)}
|
2012-04-30 21:21:50 +00:00
|
|
|
end
|
|
|
|
|
2012-05-11 19:19:38 +00:00
|
|
|
def test_find_many
|
2012-05-03 20:43:12 +00:00
|
|
|
[
|
2012-05-11 19:19:38 +00:00
|
|
|
[2, (0..15), (-1..-1), :value_string_size, :find_many_setup, :find_many, :find_many_teardown],
|
|
|
|
[2, (0..15), (-1..-1), :key_string_size, :find_many_setup, :find_many, :find_many_teardown],
|
|
|
|
[2, (0..14), (-1..-1), :array_size_fixnum, :find_many_setup, :find_many, :find_many_teardown],
|
|
|
|
[2, (0..17), (-1..-1), :hash_size_fixnum, :find_many_setup, :find_many, :find_many_teardown],
|
|
|
|
[2, (0..12), (-1..-1), :array_nest_fixnum, :find_many_setup, :find_many, :find_many_teardown],
|
|
|
|
[2, (0..15), (-1..-1), :hash_nest_fixnum, :find_many_setup, :find_many, :find_many_teardown],
|
2012-05-03 20:43:12 +00:00
|
|
|
].each{|args| @results += power_test(args)}
|
2012-04-30 21:21:50 +00:00
|
|
|
end
|
2012-04-09 15:39:57 +00:00
|
|
|
|
2012-05-11 19:19:38 +00:00
|
|
|
def test_insert_one_nest_full
|
|
|
|
[
|
|
|
|
[4, (0..6), (-1..-1), :array_nest_fixnum, :null_setup, :insert, :default_teardown],
|
|
|
|
[8, (0..4), (-1..-1), :array_nest_fixnum, :null_setup, :insert, :default_teardown],
|
|
|
|
[16, (0..3), (-1..-1), :array_nest_fixnum, :null_setup, :insert, :default_teardown],
|
|
|
|
[32, (0..2), (-1..-1), :array_nest_fixnum, :null_setup, :insert, :default_teardown],
|
|
|
|
[4, (0..8), (-1..-1), :hash_nest_fixnum, :null_setup, :insert, :default_teardown],
|
|
|
|
[8, (0..4), (-1..-1), :hash_nest_fixnum, :null_setup, :insert, :default_teardown],
|
|
|
|
[16, (0..4), (-1..-1), :hash_nest_fixnum, :null_setup, :insert, :default_teardown],
|
|
|
|
[32, (0..3), (-1..-1), :hash_nest_fixnum, :null_setup, :insert, :default_teardown],
|
|
|
|
].each{|args| @results += power_test(args)}
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_find_one_nest_full
|
2012-05-03 20:43:12 +00:00
|
|
|
[
|
2012-05-11 19:19:38 +00:00
|
|
|
[4, (0..6), (-1..-1), :array_nest_fixnum, :find_one_setup, :find_one, :default_teardown],
|
|
|
|
[8, (0..4), (-1..-1), :array_nest_fixnum, :find_one_setup, :find_one, :default_teardown],
|
|
|
|
[16, (0..3), (-1..-1), :array_nest_fixnum, :find_one_setup, :find_one, :default_teardown],
|
|
|
|
[32, (0..2), (-1..-1), :array_nest_fixnum, :find_one_setup, :find_one, :default_teardown],
|
|
|
|
[4, (0..8), (-1..-1), :hash_nest_fixnum, :find_one_setup, :find_one, :default_teardown],
|
|
|
|
[8, (0..4), (-1..-1), :hash_nest_fixnum, :find_one_setup, :find_one, :default_teardown],
|
|
|
|
[16, (0..4), (-1..-1), :hash_nest_fixnum, :find_one_setup, :find_one, :default_teardown],
|
|
|
|
[32, (0..3), (-1..-1), :hash_nest_fixnum, :find_one_setup, :find_one, :default_teardown],
|
2012-05-03 20:43:12 +00:00
|
|
|
].each{|args| @results += power_test(args)}
|
2012-04-30 21:21:50 +00:00
|
|
|
end
|
2012-04-09 15:39:57 +00:00
|
|
|
|
2012-04-30 21:21:50 +00:00
|
|
|
def xtest_update
|
2012-05-03 20:43:12 +00:00
|
|
|
[
|
2012-04-30 21:21:50 +00:00
|
|
|
# pending
|
2012-05-03 20:43:12 +00:00
|
|
|
].each{|args| @results += power_test(args)}
|
2012-04-30 21:21:50 +00:00
|
|
|
end
|
2012-04-09 15:39:57 +00:00
|
|
|
|
2012-04-30 21:21:50 +00:00
|
|
|
def xtest_remove
|
2012-05-03 20:43:12 +00:00
|
|
|
[
|
2012-04-30 21:21:50 +00:00
|
|
|
# pending
|
2012-05-03 20:43:12 +00:00
|
|
|
].each{|args| @results += power_test(args)}
|
2012-04-09 15:39:57 +00:00
|
|
|
end
|
|
|
|
|
2012-04-30 21:21:50 +00:00
|
|
|
# synthesized mix, real-world data pending
|
|
|
|
|
2012-04-09 15:39:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|