From 67099a23695d17ccae2bc5b15bce5184e3b0a72b Mon Sep 17 00:00:00 2001 From: Philippe PITTOLI Date: Thu, 9 May 2024 12:22:13 +0200 Subject: [PATCH] Benchmark RAM db. --- spec/benchmark-ramdb.cr | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 spec/benchmark-ramdb.cr diff --git a/spec/benchmark-ramdb.cr b/spec/benchmark-ramdb.cr new file mode 100644 index 0000000..bfb48dc --- /dev/null +++ b/spec/benchmark-ramdb.cr @@ -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