Commit f7290b4c authored by Philipp Götze's avatar Philipp Götze
Browse files

Added scan benchmark

parent 631ce6f5
#!/bin/bash
### LOCATIONS ###
REPO_ROOT=$PWD/..
BUILD_DIR=$REPO_ROOT/build
DATA=/mnt/pmem/test/tree_bench.data
OUTPUT_FILE=$PWD/results/scanTest.csv
### CUSTOMIZABLE PARAMETERS ###
keypos="first" #first/middle/last
lsize=512
BRANCH_SIZES=( 256 512 1024 2048 4096 )
DEPTHS=(1 2 3 4)
TREE="PBP" #FP/PBP/wBP/wHBP
TREE_BASE="PBP" # for namespace and numKeys determination
SUFFIX="" # in case of binary vs. linear
### Do not change anything following here!!! ###
### needs manual adaption ###
fillratio=1.0
KEYPOS="2"
if [ $keypos == "first" ];then
KEYPOS="ELEMENTS"
elif [ $keypos == "last" ]; then
KEYPOS="1"
fi
### adapting Tree usage ###
sed -i'' -e 's/\(.*KEYPOS = ELEMENTS\/\)\(.\+\)\(;.*\)/\1'"$KEYPOS"'\3/' $REPO_ROOT/src/bench/trees/common.hpp
sed -i'' -e 's/\(.*LEAF_SIZE = \)\([0-9]\+\)\(.*\)/\1'"$lsize"'\3/' $REPO_ROOT/src/bench/trees/common.hpp
sed -i'' -e 's/\(.*\"\).*\(Tree.hpp\"\)/\1'"$TREE"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #include
sed -i'' -e 's/\(.*dbis::\).*\(tree;\)/\1'"${TREE_BASE,,}"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #namespace
sed -i'' -e 's/\(.*LEAFKEYS = getLeafKeys\).*\(Tree.*\)/\1'"$TREE_BASE"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #keys
sed -i'' -e 's/\(.*BRANCHKEYS = getBranchKeys\).*\(Tree.*\)/\1'"$TREE_BASE"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #keys
sed -i'' -e 's/\(.*TreeType = \).*\(Tree.*\)/\1'"$TREE"'\2/' $REPO_ROOT/src/bench/trees/common.hpp #type
echo -n "Running benchmarks for ${Tree}Tree..."
for depth in "${DEPTHS[@]}"
do
echo -en "\nTarget depth: $depth - "
sed -i'' -e 's/\(.*DEPTH = \)\([0-9]\+\)\(.*\)/\1'"$depth"'\3/' $REPO_ROOT/src/bench/trees/common.hpp
for bsize in "${BRANCH_SIZES[@]}"
do
echo -n "$bsize "
sed -i'' -e 's/\(.*BRANCH_SIZE = \)\([0-9]\+\)\(.*\)/\1'"$bsize"'\3/' $REPO_ROOT/src/bench/trees/common.hpp
rm -rf $DATA
pushd $BUILD_DIR > /dev/null
make tree_scan > /dev/null
for r in {1..3}
do
OUTPUT="$(sh -c 'bench/tree_scan --benchmark_format=csv' 2> /dev/null | tail -3)"
elements="$(echo "$OUTPUT" | head -1 | cut -d ':' -f2)"
time="$(echo "$OUTPUT" | tail -1 | cut -d ',' -f4)"
echo "${TREE}Tree$SUFFIX,$elements,$lsize,$bsize,$depth,$fillratio,$keypos,$time" >> $OUTPUT_FILE
done
popd > /dev/null
done
done
echo -e "\nFinished. Results in $OUTPUT_FILE"
......@@ -3,10 +3,11 @@ include(../../cmake/Testing.cmake.in)
if (BUILD_BENCHMARKS)
do_bench(trees/tree_get)
do_bench(trees/tree_traverse)
do_bench(trees/tree_scan)
do_bench(trees/tree_insert)
do_bench(trees/tree_split)
# PTABLE
do_bench(ptable/insert ptable)
#do_bench(ptable/insert ptable)
do_bench(ptable/scan ptable)
do_bench(ptable/point ptable)
endif()
/*
* Copyright (C) 2017-2019 DBIS Group - TU Ilmenau, All Rights Reserved.
*
* This file is part of our NVM-based Data Structures repository.
*
* 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.
*
* 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.
*
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "common.hpp"
/* Scan benchmarks on Tree */
static void BM_TreeScan(benchmark::State &state) {
std::cout << "BRANCHKEYS: " << BRANCHKEYS //<< " --> " << BRANCHSIZE
<< "\nLEAFKEYS: " << LEAFKEYS //<< " --> " << LEAFSIZE
<< "\n";
struct root {
persistent_ptr<TreeType> tree;
};
pool<root> pop;
if (access(path.c_str(), F_OK) != 0) {
pop = pool<root>::create(path, LAYOUT, POOL_SIZE);
transaction::run(pop, [&] {
pop.root()->tree = make_persistent<TreeType>();
});
insert(pop.root()->tree);
} else {
LOG("Warning: " << path << " already exists");
pop = pool<root>::open(path, LAYOUT);
hybridWrapper.recover(*pop.root()->tree);
}
auto tree = pop.root()->tree;
auto &treeRef = *tree;
auto node = treeRef.rootNode;
/* BENCHMARKING */
for (auto _ : state) {
//benchmark::DoNotOptimize(
treeRef.scan([](const auto& k, const auto& v) {
const auto key = k;
});
//);
//auto p = treeRef.lookupPositionInLeafNode(leaf, 1);
}
//treeRef.printBranchNode(0, treeRef.rootNode.branch);
std::cout << "Elements:" << ELEMENTS << "\n";
transaction::run(pop, [&] { delete_persistent<TreeType>(tree); });
pop.close();
std::experimental::filesystem::remove_all(path);
}
BENCHMARK(BM_TreeScan);
BENCHMARK_MAIN();
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment