31 lines
829 B
Crystal
31 lines
829 B
Crystal
|
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
|