Benchmarks: provide reports to simplify the code for statistical analysis.

This commit is contained in:
Philippe PITTOLI 2024-05-12 14:34:38 +02:00
parent f43669b3b7
commit 12732277d3

View File

@ -29,6 +29,18 @@ class Context
class_property incr = 1_000 class_property incr = 1_000
end end
# To simplify the creation of graphs, it's better to have fake data for
# partitions and tags that won't be actually covered.
# 0 means the absence of data.
def fake_report(name)
durations = Array(Int32).new Context.nb_run, 0
File.open("#{Context.report_dir}/#{name}.raw", "w") do |file|
durations.each do |d|
file.puts d
end
end
puts "#{name}: no report"
end
def report(storage, name, &block) def report(storage, name, &block)
durations = run_n_times Context.nb_run, &block durations = run_n_times Context.nb_run, &block
File.open("#{Context.report_dir}/#{name}.raw", "w") do |file| File.open("#{Context.report_dir}/#{name}.raw", "w") do |file|
@ -98,12 +110,17 @@ def batch()
report(storage, "#{name}_#{current_db_size}_index") do report(storage, "#{name}_#{current_db_size}_index") do
corvet = search_name.get name_to_search corvet = search_name.get name_to_search
end end
if current_db_size <= Context.max_indexes
report(storage, "#{name}_#{current_db_size}_partitions") do report(storage, "#{name}_#{current_db_size}_partitions") do
corvet = search_color.get? color_to_search corvet = search_color.get? color_to_search
end end
report(storage, "#{name}_#{current_db_size}_tags") do report(storage, "#{name}_#{current_db_size}_tags") do
corvet = search_keywords.get? keyword_to_search corvet = search_keywords.get? keyword_to_search
end end
else
fake_report("#{name}_#{current_db_size}_partitions")
fake_report("#{name}_#{current_db_size}_tags")
end
} }
prepare_env cars_cached, "cached", cached_Sby_name, cached_Sby_color, cached_Sby_keywords, &fn prepare_env cars_cached, "cached", cached_Sby_name, cached_Sby_color, cached_Sby_keywords, &fn