Add some basic benchmark for adding values in different database types.
This commit is contained in:
parent
a7a9aa59c9
commit
ae81e31513
@ -79,31 +79,51 @@ Benchmark.ips do |x|
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#cars_ram.rm_storage_dir
|
cars_ram.rm_storage_dir
|
||||||
#cars_cached.rm_storage_dir
|
cars_cached.rm_storage_dir
|
||||||
#cars_semi.rm_storage_dir
|
cars_semi.rm_storage_dir
|
||||||
#cars_uncached.rm_storage_dir
|
cars_uncached.rm_storage_dir
|
||||||
|
|
||||||
#cars_cached = DODB::CachedSpecDataBase(Car).new
|
cars_ram = DODB::RAMOnlySpecDataBase(Car).new
|
||||||
#cars_uncached = DODB::SpecDataBase(Car).new
|
cars_cached = DODB::CachedSpecDataBase(Car).new
|
||||||
#
|
cars_semi = DODB::SpecDataBase(Car).new "-semi"
|
||||||
##init_indexes cars_cached
|
cars_uncached = DODB::SpecDataBase(Car).new
|
||||||
##init_indexes cars_uncached
|
|
||||||
#cached_searchby_name, cached_searchby_color, cached_searchby_keywords = cached_indexes cars_cached
|
ram_searchby_name, ram_searchby_color, ram_searchby_keywords = ram_indexes cars_ram
|
||||||
#uncached_searchby_name, uncached_searchby_color, uncached_searchby_keywords = uncached_indexes cars_uncached
|
cached_searchby_name, cached_searchby_color, cached_searchby_keywords = cached_indexes cars_cached
|
||||||
#
|
semi_searchby_name, semi_searchby_color, semi_searchby_keywords = cached_indexes cars_semi
|
||||||
#add_cars cars_cached, 1_000
|
uncached_searchby_name, uncached_searchby_color, uncached_searchby_keywords = uncached_indexes cars_uncached
|
||||||
#add_cars cars_uncached, 1_000
|
|
||||||
#
|
add_cars cars_ram, 1_000
|
||||||
#nb_run = 1000
|
add_cars cars_cached, 1_000
|
||||||
#
|
add_cars cars_semi, 1_000
|
||||||
#perform_benchmark_average_verbose "(cached) search db with an index", nb_run, do
|
add_cars cars_uncached, 1_000
|
||||||
# cached_searchby_name.get "Corvet-500"
|
|
||||||
#end
|
def perform_add(storage : DODB::Storage(Car), nb_run)
|
||||||
#
|
corvet0 = Car.new "Corvet", "red", [ "shiny", "impressive", "fast", "elegant" ]
|
||||||
#perform_benchmark_average_verbose "(uncached) search db with an index", nb_run, do
|
i = 0
|
||||||
# uncached_searchby_name.get "Corvet-500"
|
perform_benchmark_average nb_run, do
|
||||||
#end
|
corvet = corvet0.clone
|
||||||
#
|
corvet.name = "Corvet-add-#{i}"
|
||||||
#cars_cached.rm_storage_dir
|
storage << corvet
|
||||||
#cars_uncached.rm_storage_dir
|
i += 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
nb_run = 1000
|
||||||
|
avr = perform_add(cars_ram, nb_run)
|
||||||
|
puts "(ram db and indexes) add a value (average on #{nb_run} tries): #{avr}"
|
||||||
|
|
||||||
|
avr = perform_add(cars_cached, nb_run)
|
||||||
|
puts "(cached db and indexes) add a value (average on #{nb_run} tries): #{avr}"
|
||||||
|
|
||||||
|
avr = perform_add(cars_semi, nb_run)
|
||||||
|
puts "(uncached db but cached indexes) add a value (average on #{nb_run} tries): #{avr}"
|
||||||
|
|
||||||
|
avr = perform_add(cars_uncached, nb_run)
|
||||||
|
puts "(uncached db and indexes) add a value (average on #{nb_run} tries): #{avr}"
|
||||||
|
|
||||||
|
cars_ram.rm_storage_dir
|
||||||
|
cars_cached.rm_storage_dir
|
||||||
|
cars_semi.rm_storage_dir
|
||||||
|
cars_uncached.rm_storage_dir
|
||||||
|
Loading…
Reference in New Issue
Block a user