Benchmark RAM db.

toying-with-ramdb
Philippe PITTOLI 2024-05-09 12:22:13 +02:00
parent 90b6563068
commit 835626a6dd
1 changed files with 30 additions and 0 deletions

30
spec/benchmark-ramdb.cr Normal file
View File

@ -0,0 +1,30 @@
require "benchmark"
require "./benchmark-utilities.cr"
require "./cars.cr"
cars_ram = DODB::RAMOnlySpecDataBase(Car).new
cached_searchby_name, cached_searchby_color, cached_searchby_keywords = ram_indexes cars_ram
add_cars cars_ram, 1_000
# Searching for data with an index.
Benchmark.ips do |x|
x.report("(cars db) searching a data with an index (with a cache)") do
corvet = cached_searchby_name.get "Corvet-500"
end
end
# Searching for data with a partition.
Benchmark.ips do |x|
x.report("(cars db) searching a data with a partition (with a cache)") do
red_cars = cached_searchby_color.get "red"
end
end
# Searching for data with a tag.
Benchmark.ips do |x|
x.report("(cars db) searching a data with a tag (with a cache)") do
red_cars = cached_searchby_keywords.get "spacious"
end
end
cars_ram.rm_storage_dir