Skip to content

Commit

Permalink
More benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
tinloaf committed Jul 29, 2020
1 parent d4d3f35 commit be653ca
Show file tree
Hide file tree
Showing 5 changed files with 311 additions and 20 deletions.
91 changes: 89 additions & 2 deletions benchmark/bench_bst_delete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,35 @@ BENCHMARK_DEFINE_F(DeleteYggRBBSTFixture, BM_BST_Deletion)
}
REGISTER(DeleteYggRBBSTFixture, BM_BST_Deletion)

/*
* Ygg's Red-Black Tree, using color compression
*/
using DeleteYggRBBSTFixtureCC =
BSTFixture<YggRBTreeInterface<RBColorCompressTreeOptions>, DeleteExperiment,
BSTDeleteOptions>;
BENCHMARK_DEFINE_F(DeleteYggRBBSTFixtureCC, BM_BST_Deletion)
(benchmark::State & state)
{
Clock c;
for (auto _ : state) {
c.start();
this->papi.start();
for (auto n : this->experiment_node_pointers) {
this->t.remove(*n);
}
this->papi.stop();
state.SetIterationTime(c.get());

for (auto n : this->experiment_node_pointers) {
this->t.insert(*n);
}
// TODO shuffling here?
}

this->papi.report_and_reset(state);
}
REGISTER(DeleteYggRBBSTFixtureCC, BM_BST_Deletion)

/*
* Ygg's Red-Black Tree, avoiding conditional branches
*/
Expand Down Expand Up @@ -302,9 +331,9 @@ BENCHMARK_DEFINE_F(DeleteYggEBSTFixture, BM_BST_Deletion)
REGISTER(DeleteYggEBSTFixture, BM_BST_Deletion)

/*
* Ygg's Zip Tree
* Ygg's Zip Tree, using randomness
*/
using DeleteYggZBSTFixture = BSTFixture<YggZTreeInterface<BasicTreeOptions>,
using DeleteYggZBSTFixture = BSTFixture<YggZTreeInterface<ZRandomTreeOptions>,
DeleteExperiment, BSTDeleteOptions>;
BENCHMARK_DEFINE_F(DeleteYggZBSTFixture, BM_BST_Deletion)
(benchmark::State & state)
Expand All @@ -329,6 +358,64 @@ BENCHMARK_DEFINE_F(DeleteYggZBSTFixture, BM_BST_Deletion)
}
REGISTER(DeleteYggZBSTFixture, BM_BST_Deletion)

/*
* Ygg's Zip Tree, using hashing
*/
using DeleteYggZBSTFixtureHashing =
BSTFixture<YggZTreeInterface<ZHashTreeOptions>, DeleteExperiment,
BSTDeleteOptions>;
BENCHMARK_DEFINE_F(DeleteYggZBSTFixtureHashing, BM_BST_Deletion)
(benchmark::State & state)
{
Clock c;
for (auto _ : state) {
c.start();
this->papi.start();
for (auto n : this->experiment_node_pointers) {
this->t.remove(*n);
}
this->papi.stop();
state.SetIterationTime(c.get());

for (auto n : this->experiment_node_pointers) {
this->t.insert(*n);
}
// TODO shuffling here?
}

this->papi.report_and_reset(state);
}
REGISTER(DeleteYggZBSTFixtureHashing, BM_BST_Deletion)

/*
* Ygg's Zip Tree, using hashing + universalization
*/
using DeleteYggZBSTFixtureHUL =
BSTFixture<YggZTreeInterface<ZUnivHashTreeOptions>, DeleteExperiment,
BSTDeleteOptions>;
BENCHMARK_DEFINE_F(DeleteYggZBSTFixtureHUL, BM_BST_Deletion)
(benchmark::State & state)
{
Clock c;
for (auto _ : state) {
c.start();
this->papi.start();
for (auto n : this->experiment_node_pointers) {
this->t.remove(*n);
}
this->papi.stop();
state.SetIterationTime(c.get());

for (auto n : this->experiment_node_pointers) {
this->t.insert(*n);
}
// TODO shuffling here?
}

this->papi.report_and_reset(state);
}
REGISTER(DeleteYggZBSTFixtureHUL, BM_BST_Deletion)

/*
* Boost::Intrusive::Set
*/
Expand Down
88 changes: 86 additions & 2 deletions benchmark/bench_bst_insert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,35 @@ BENCHMARK_DEFINE_F(InsertYggRBBSTFixtureArith, BM_BST_Insertion)
}
REGISTER(InsertYggRBBSTFixtureArith, BM_BST_Insertion)

/*
* Ygg's Red-Black Tree, using color-compression
*/
using InsertYggRBBSTFixtureCC =
BSTFixture<YggRBTreeInterface<RBColorCompressTreeOptions>, InsertExperiment,
BSTInsertOptions>;
BENCHMARK_DEFINE_F(InsertYggRBBSTFixtureCC, BM_BST_Insertion)
(benchmark::State & state)
{
Clock c;
for (auto _ : state) {
c.start();
this->papi.start();
for (auto & n : this->experiment_nodes) {
this->t.insert(n);
}
this->papi.stop();
state.SetIterationTime(c.get());

for (auto & n : this->experiment_nodes) {
this->t.remove(n);
}
// TODO shuffling here?
}

this->papi.report_and_reset(state);
}
REGISTER(InsertYggRBBSTFixtureCC, BM_BST_Insertion)

/*
* Ygg's Weight-Balanced Tree
*/
Expand Down Expand Up @@ -322,9 +351,9 @@ BENCHMARK_DEFINE_F(InsertYggEBSTFixture, BM_BST_Insertion)
REGISTER(InsertYggEBSTFixture, BM_BST_Insertion)

/*
* Ygg's Zip Tree
* Ygg's Zip Tree, using randomness
*/
using InsertYggZBSTFixture = BSTFixture<YggZTreeInterface<BasicTreeOptions>,
using InsertYggZBSTFixture = BSTFixture<YggZTreeInterface<ZRandomTreeOptions>,
InsertExperiment, BSTInsertOptions>;
BENCHMARK_DEFINE_F(InsertYggZBSTFixture, BM_BST_Insertion)
(benchmark::State & state)
Expand All @@ -348,6 +377,61 @@ BENCHMARK_DEFINE_F(InsertYggZBSTFixture, BM_BST_Insertion)
}
REGISTER(InsertYggZBSTFixture, BM_BST_Insertion)

/*
* Ygg's Zip Tree, using hashing
*/
using InsertYggZBSTFixtureHash = BSTFixture<YggZTreeInterface<ZHashTreeOptions>,
InsertExperiment, BSTInsertOptions>;
BENCHMARK_DEFINE_F(InsertYggZBSTFixtureHash, BM_BST_Insertion)
(benchmark::State & state)
{
Clock c;
for (auto _ : state) {
c.start();
this->papi.start();
for (auto & n : this->experiment_nodes) {
this->t.insert(n);
}
this->papi.stop();
state.SetIterationTime(c.get());

for (auto & n : this->experiment_nodes) {
this->t.remove(n);
}
// TODO shuffling here?
}
this->papi.report_and_reset(state);
}
REGISTER(InsertYggZBSTFixtureHash, BM_BST_Insertion)

/*
* Ygg's Zip Tree, using hashing + universalization
*/
using InsertYggZBSTFixtureHUL =
BSTFixture<YggZTreeInterface<ZUnivHashTreeOptions>, InsertExperiment,
BSTInsertOptions>;
BENCHMARK_DEFINE_F(InsertYggZBSTFixtureHUL, BM_BST_Insertion)
(benchmark::State & state)
{
Clock c;
for (auto _ : state) {
c.start();
this->papi.start();
for (auto & n : this->experiment_nodes) {
this->t.insert(n);
}
this->papi.stop();
state.SetIterationTime(c.get());

for (auto & n : this->experiment_nodes) {
this->t.remove(n);
}
// TODO shuffling here?
}
this->papi.report_and_reset(state);
}
REGISTER(InsertYggZBSTFixtureHUL, BM_BST_Insertion)

/*
* Boost::Intrusive::Set
*/
Expand Down
38 changes: 38 additions & 0 deletions benchmark/bench_bst_move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,44 @@ BENCHMARK_DEFINE_F(MoveYggRBBSTFixture, BM_BST_Move)
}
REGISTER(MoveYggRBBSTFixture, BM_BST_Move)

/*
* Ygg's Red-Black Tree, using color compression
*/
using MoveYggRBBSTFixtureCC =
BSTFixture<YggRBTreeInterface<RBColorCompressTreeOptions>, MoveExperiment,
BSTMoveOptions>;
BENCHMARK_DEFINE_F(MoveYggRBBSTFixtureCC, BM_BST_Move)
(benchmark::State & state)
{
Clock c;
for (auto _ : state) {
c.start();
this->papi.start();
for (size_t i = 0; i < this->experiment_node_pointers.size(); i++) {
auto * n = this->experiment_node_pointers[i];
auto new_val = this->experiment_values[i];

this->t.remove(*n);
NodeInterface::set_value(*n, new_val);
this->t.insert(*n);
}
this->papi.stop();
state.SetIterationTime(c.get());

for (size_t i = 0; i < this->experiment_node_pointers.size(); i++) {
auto * n = this->experiment_node_pointers[i];
auto old_val = this->fixed_values[i];

this->t.remove(*n);
NodeInterface::set_value(*n, old_val);
this->t.insert(*n);
}
}

this->papi.report_and_reset(state);
}
REGISTER(MoveYggRBBSTFixtureCC, BM_BST_Move)

/*
* Ygg's Red-Black Tree, avoiding conditional branches
*/
Expand Down
77 changes: 75 additions & 2 deletions benchmark/bench_bst_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,32 @@ BENCHMARK_DEFINE_F(SearchYggRBBSTFixture, BM_BST_Search)
}
REGISTER(SearchYggRBBSTFixture, BM_BST_Search)

/*
* Ygg's Red-Black Tree, using color compression
*/
using SearchYggRBBSTFixtureCC =
BSTFixture<YggRBTreeInterface<RBColorCompressTreeOptions>, SearchExperiment,
BSTSearchOptions>;
BENCHMARK_DEFINE_F(SearchYggRBBSTFixtureCC, BM_BST_Search)
(benchmark::State & state)
{
Clock c;
for (auto _ : state) {
c.start();
this->papi.start();
for (auto val : this->experiment_values) {
auto node = this->t.find(val);
benchmark::DoNotOptimize(node);
}
this->papi.stop();
state.SetIterationTime(c.get());
// TODO shuffling?
}

this->papi.report_and_reset(state);
}
REGISTER(SearchYggRBBSTFixtureCC, BM_BST_Search)

/*
* Ygg's weight-balanced tree, default parameters, two-pass
*/
Expand Down Expand Up @@ -221,9 +247,9 @@ BENCHMARK_DEFINE_F(SearchYggWB32SPBSTFixture, BM_BST_Search)
REGISTER(SearchYggWB32SPBSTFixture, BM_BST_Search)

/*
* Ygg's Zip Tree
* Ygg's Zip Tree, using randomness
*/
using SearchYggZBSTFixture = BSTFixture<YggZTreeInterface<BasicTreeOptions>,
using SearchYggZBSTFixture = BSTFixture<YggZTreeInterface<ZRandomTreeOptions>,
SearchExperiment, BSTSearchOptions>;
BENCHMARK_DEFINE_F(SearchYggZBSTFixture, BM_BST_Search)
(benchmark::State & state)
Expand All @@ -243,6 +269,53 @@ BENCHMARK_DEFINE_F(SearchYggZBSTFixture, BM_BST_Search)
}
REGISTER(SearchYggZBSTFixture, BM_BST_Search)

/*
* Ygg's Zip Tree, using hashing + universalization
*/
using SearchYggZBSTFixtureHUL =
BSTFixture<YggZTreeInterface<ZUnivHashTreeOptions>, SearchExperiment,
BSTSearchOptions>;
BENCHMARK_DEFINE_F(SearchYggZBSTFixtureHUL, BM_BST_Search)
(benchmark::State & state)
{
Clock c;
for (auto _ : state) {
c.start();
this->papi.start();
for (auto val : this->experiment_values) {
auto node = this->t.find(val);
benchmark::DoNotOptimize(node);
}
this->papi.stop();
state.SetIterationTime(c.get());
}
this->papi.report_and_reset(state);
}
REGISTER(SearchYggZBSTFixtureHUL, BM_BST_Search)

/*
* Ygg's Zip Tree, using hashing
*/
using SearchYggZBSTFixtureHash = BSTFixture<YggZTreeInterface<ZHashTreeOptions>,
SearchExperiment, BSTSearchOptions>;
BENCHMARK_DEFINE_F(SearchYggZBSTFixtureHash, BM_BST_Search)
(benchmark::State & state)
{
Clock c;
for (auto _ : state) {
c.start();
this->papi.start();
for (auto val : this->experiment_values) {
auto node = this->t.find(val);
benchmark::DoNotOptimize(node);
}
this->papi.stop();
state.SetIterationTime(c.get());
}
this->papi.report_and_reset(state);
}
REGISTER(SearchYggZBSTFixtureHash, BM_BST_Search)

/*
* Boost::Intrusive::Set
*/
Expand Down
Loading

0 comments on commit be653ca

Please sign in to comment.