From 1e6814f4db0cb50114167bebc536afe9c528fbac Mon Sep 17 00:00:00 2001 From: Philippe PITTOLI Date: Sun, 12 May 2024 14:34:38 +0200 Subject: [PATCH] Benchmarks: provide reports to simplify the code for statistical analysis. --- spec/benchmark-cars.cr | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/spec/benchmark-cars.cr b/spec/benchmark-cars.cr index bb1f535..42c042a 100644 --- a/spec/benchmark-cars.cr +++ b/spec/benchmark-cars.cr @@ -29,6 +29,18 @@ class Context class_property incr = 1_000 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) durations = run_n_times Context.nb_run, &block File.open("#{Context.report_dir}/#{name}.raw", "w") do |file| @@ -98,11 +110,16 @@ def batch() report(storage, "#{name}_#{current_db_size}_index") do corvet = search_name.get name_to_search end - report(storage, "#{name}_#{current_db_size}_partitions") do - corvet = search_color.get? color_to_search - end - report(storage, "#{name}_#{current_db_size}_tags") do - corvet = search_keywords.get? keyword_to_search + if current_db_size <= Context.max_indexes + report(storage, "#{name}_#{current_db_size}_partitions") do + corvet = search_color.get? color_to_search + end + report(storage, "#{name}_#{current_db_size}_tags") do + corvet = search_keywords.get? keyword_to_search + end + else + fake_report("#{name}_#{current_db_size}_partitions") + fake_report("#{name}_#{current_db_size}_tags") end }