Benchmark RAM db.
This commit is contained in:
parent
52462d141e
commit
67099a2369
30
spec/benchmark-ramdb.cr
Normal file
30
spec/benchmark-ramdb.cr
Normal 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
|
Loading…
Reference in New Issue
Block a user