point.cpp 1.85 KB
Newer Older
Philipp Götze's avatar
Philipp Götze committed
1
/*
2
 * Copyright (C) 2017-2019 DBIS Group - TU Ilmenau, All Rights Reserved.
Philipp Götze's avatar
Philipp Götze committed
3
 *
4
 * This file is part of our NVM-based Data Structures repository.
Philipp Götze's avatar
Philipp Götze committed
5
 *
6
7
8
 * This program is free software: you can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
Philipp Götze's avatar
Philipp Götze committed
9
 *
10
11
12
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
Philipp Götze's avatar
Philipp Götze committed
13
 *
14
15
 * You should have received a copy of the GNU General Public License along with this program.
 * If not, see <http://www.gnu.org/licenses/>.
Philipp Götze's avatar
Philipp Götze committed
16
17
18
 */

#include <unistd.h>
Philipp Götze's avatar
Philipp Götze committed
19

Philipp Götze's avatar
Philipp Götze committed
20
21
#include "benchmark/benchmark.h"
#include "fmt/format.h"
Philipp Götze's avatar
Philipp Götze committed
22

23
#include "common.hpp"
Philipp Götze's avatar
Philipp Götze committed
24
25
26
27
28
29
30
31

using namespace dbis::ptable;

static void BM_PointQuery(benchmark::State& state) {
  pool<root> pop;

  const std::string path = dbis::gPmemPath + "benchdb" + std::to_string(state.range(0)) + ".db";

32
  // std::remove(path.c_str());
Philipp Götze's avatar
Philipp Götze committed
33
34
35
  if (access(path.c_str(), F_OK) != 0) {
    insert(pop, path, state.range(0));
  } else {
36
    // std::cerr << "WARNING: Table already exists" << std::endl;
Philipp Götze's avatar
Philipp Götze committed
37
38
39
    pop = pool<root>::open(path, LAYOUT);
  }

40
  auto& pTable = *pop.root()->pTable;
Philipp Götze's avatar
Philipp Götze committed
41
42

  for (auto _ : state) {
43
    auto ptp = pTable.getByKey(state.range(1));
44
45
46
47
    if (ptp.getNode() != nullptr)
      ptp;  // ptp.createTuple();
    else
      std::cerr << "key not found" << '\n';
Philipp Götze's avatar
Philipp Götze committed
48
  }
49
50

  transaction::run(pop, [&] { delete_persistent<PTableType>(pop.root()->pTable); });
Philipp Götze's avatar
Philipp Götze committed
51
  pop.close();
52
  pmempool_rm(path.c_str(), 0);
Philipp Götze's avatar
Philipp Götze committed
53
54
}
static void VectorArguments(benchmark::internal::Benchmark* b) {
55
  for (const auto& arg : POINT_ACCESS) b->Args(arg);
Philipp Götze's avatar
Philipp Götze committed
56
57
58
59
}
BENCHMARK(BM_PointQuery)->Apply(VectorArguments);

BENCHMARK_MAIN();