From 0e8d1ef77ad8db2b2491ae92874eb21b7986d59b Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Tue, 13 Jun 2023 14:48:03 -0400 Subject: Benchmark refactoring/cleanup --- benchmarks/include/bench_utility.h | 47 +++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 11 deletions(-) (limited to 'benchmarks/include/bench_utility.h') diff --git a/benchmarks/include/bench_utility.h b/benchmarks/include/bench_utility.h index 78d6415..f208487 100644 --- a/benchmarks/include/bench_utility.h +++ b/benchmarks/include/bench_utility.h @@ -1,5 +1,13 @@ -#ifndef H_BENCH -#define H_BENCH +/* + * benchmarks/include/bench_utility.h + * + * Copyright (C) 2023 Douglas Rumbaugh + * + * All rights reserved. Published under the Modified BSD License. + * + */ +#pragma once + #include "framework/DynamicExtension.h" #include "shard/WSS.h" #include "shard/MemISAM.h" @@ -29,7 +37,7 @@ typedef de::WeightedRecord WRec; typedef de::Record Rec; typedef de::DynamicExtension, de::WSSQuery> ExtendedWSS; -typedef de::DynamicExtension, de::TrieSplineRangeQuery> ExtendedTS; +typedef de::DynamicExtension, de::TrieSplineRangeQuery> ExtendedTSRQ; typedef de::DynamicExtension, de::PGMRangeQuery> ExtendedPGM; static gsl_rng *g_rng; @@ -82,6 +90,31 @@ static void delete_bench_env() delete g_to_delete; } +/* + * NOTE: The QP type must have lower_bound and upper_bound attributes, which + * this function will initialize. Any other query parameter attributes must + * be manually initialized after the call. + */ +template +static std::vector read_range_queries(std::string fname, double selectivity) { + std::vector queries; + + FILE *qf = fopen(fname.c_str(), "r"); + size_t start, stop; + double sel; + while (fscanf(qf, "%zu%zu%lf\n", &start, &stop, &sel) != EOF) { + if (start < stop && std::abs(sel - selectivity) < 0.1) { + QP q; + q.lower_bound = start; + q.upper_bound = stop; + queries.push_back(q); + } + } + fclose(qf); + + return queries; +} + template static bool next_record(std::fstream &file, R &record) { @@ -213,12 +246,6 @@ static bool warmup(std::fstream &file, DE &extended_index, size_t count, } } - /* - if (progress) { - progress_update(1, "warming up:"); - } - */ - return true; } @@ -232,5 +259,3 @@ static void reset_de_perf_metrics() { RESET_IO_CNT(); } - -#endif // H_BENCH -- cgit v1.2.3