Skip to content

Commit

Permalink
feature: code style restructuring, more OO programming paradigms
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelkallis committed Oct 25, 2018
1 parent c7448dd commit 01b6a4e
Show file tree
Hide file tree
Showing 24 changed files with 477 additions and 490 deletions.
30 changes: 0 additions & 30 deletions bench/node_0.cpp

This file was deleted.

24 changes: 12 additions & 12 deletions bench/node_16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ PICOBENCH_SUITE("node_16");

static void node_16_constructor(state &s) {
for (auto _ : s) {
node_16<void *> n;
node_16<int> n;
}
}
PICOBENCH(node_16_constructor);

static void node_16_find_child(state &s) {
node_16<void *> n;
node_0<void *> child;
node_16<int> n;
leaf_node<int> child(nullptr);
for (int i = 0; i < 16; ++i) {
n.set_child((i * 17) - 128, &child);
}
Expand All @@ -31,12 +31,12 @@ static void node_16_find_child(state &s) {
PICOBENCH(node_16_find_child);

static void node_16_set_child(state &s) {
node_16<void *> *n = new node_16<void *>();
node_0<void *> child;
auto n = new node_16<int>();
leaf_node<int> child(nullptr);
for (auto _ : s) {
if (n->is_full()) {
delete n;
n = new node_16<void *>();
n = new node_16<int>();
}
n->set_child(((rand() % 16) * 17) - 128, &child);
}
Expand All @@ -45,16 +45,16 @@ PICOBENCH(node_16_set_child);

static void node_16_grow(state &s) {
for (auto _ : s) {
node_16<void *> *n = new node_16<void *>();
node<void *> *new_n = n->grow();
auto *n = new node_16<int>();
auto *new_n = n->grow();
delete new_n;
}
}
PICOBENCH(node_16_grow);

static void node_16_next_partial_key(state &s) {
node_16<void *> n;
node_0<void *> child;
node_16<int> n;
leaf_node<int> child(nullptr);
for (int i = 0; i < 16; ++i) {
n.set_child((i * 17) - 128, &child);
}
Expand All @@ -65,8 +65,8 @@ static void node_16_next_partial_key(state &s) {
PICOBENCH(node_16_next_partial_key);

static void node_16_prev_partial_key(state &s) {
node_16<void *> n;
node_0<void *> child;
node_16<int> n;
leaf_node<int> child(nullptr);
for (int i = 0; i < 16; ++i) {
n.set_child((i * 17) - 128, &child);
}
Expand Down
20 changes: 10 additions & 10 deletions bench/node_256.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ PICOBENCH_SUITE("node_256");

static void node_256_constructor(state &s) {
for (auto _ : s) {
node_256<void *> n;
node_256<int> n;
}
}
PICOBENCH(node_256_constructor);

static void node_256_find_child(state &s) {
node_256<void *> n;
node_0<void *> child;
node_256<int> n;
leaf_node<int> child(nullptr);
for (int i = 0; i < 256; ++i) {
n.set_child(i - 128, &child);
}
Expand All @@ -31,21 +31,21 @@ static void node_256_find_child(state &s) {
PICOBENCH(node_256_find_child);

static void node_256_set_child(state &s) {
node_256<void *> *n = new node_256<void *>();
node_0<void *> child;
node_256<int> *n = new node_256<int>();
leaf_node<int> child(nullptr);
for (auto _ : s) {
if (n->is_full()) {
delete n;
n = new node_256<void *>();
n = new node_256<int>();
}
n->set_child((rand() % 256) - 128, &child);
}
}
PICOBENCH(node_256_set_child);

static void node_256_next_partial_key(state &s) {
node_256<void *> n;
node_0<void *> child;
node_256<int> n;
leaf_node<int> child(nullptr);
for (int i = 0; i < 256; ++i) {
n.set_child(i - 128, &child);
}
Expand All @@ -56,8 +56,8 @@ static void node_256_next_partial_key(state &s) {
PICOBENCH(node_256_next_partial_key);

static void node_256_prev_partial_key(state &s) {
node_256<void *> n;
node_0<void *> child;
node_256<int> n;
leaf_node<int> child(nullptr);
for (int i = 0; i < 256; ++i) {
n.set_child(i - 128, &child);
}
Expand Down
46 changes: 23 additions & 23 deletions bench/node_4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,40 @@ PICOBENCH_SUITE("node_4");

static void node_4_constructor(state &s) {
for (auto _ : s) {
node_4<void *> n;
node_4<int> n;
}
}
PICOBENCH(node_4_constructor);

static void node_4_find_child(state &s) {
node_4<void *> n;
node_4<int> n;

node_0<void *> c0;
node_0<void *> c1;
node_0<void *> c2;
node_0<void *> c3;
leaf_node<int> c0(nullptr);
leaf_node<int> c1(nullptr);
leaf_node<int> c2(nullptr);
leaf_node<int> c3(nullptr);

n.set_child(-128, &c0);
n.set_child(-43, &c1);
n.set_child(42, &c2);
n.set_child(127, &c3);

char partial_keys[] = {-128, -43, 42, 127};
node<void *> **child = nullptr;
node<int> **child = nullptr;
for (auto _ : s) {
child = n.find_child(partial_keys[rand() % 4]);
}
}
PICOBENCH(node_4_find_child);

static void node_4_set_child(state &s) {
node_4<void *> *n = new node_4<void *>();
node_0<void *> child;
auto n = new node_4<int>();
leaf_node<int> child(nullptr);
char partial_keys[] = {-128, -43, 42, 127};
for (auto _ : s) {
if (n->is_full()) {
delete n;
n = new node_4<void *>();
n = new node_4<int>();
}

n->set_child(partial_keys[rand() % 4], &child);
Expand All @@ -55,23 +55,23 @@ static void node_4_set_child(state &s) {
PICOBENCH(node_4_set_child);

static void node_4_grow(state &s) {
node<void *> *n = nullptr;
node<void *> *new_n = nullptr;
inner_node<int> *n = nullptr;
inner_node<int> *new_n = nullptr;
for (auto _ : s) {
n = new node_4<void *>();
n = new node_4<int>();
new_n = n->grow();
delete new_n;
}
}
PICOBENCH(node_4_grow);

static void node_4_next_partial_key(state &s) {
node_4<void *> n;
node_4<int> n;

node_0<void *> c0;
node_0<void *> c1;
node_0<void *> c2;
node_0<void *> c3;
leaf_node<int> c0(nullptr);
leaf_node<int> c1(nullptr);
leaf_node<int> c2(nullptr);
leaf_node<int> c3(nullptr);

n.set_child(-128, &c0);
n.set_child(-43, &c1);
Expand All @@ -85,12 +85,12 @@ static void node_4_next_partial_key(state &s) {
PICOBENCH(node_4_next_partial_key);

static void node_4_prev_partial_key(state &s) {
node_4<void *> n;
node_4<int> n;

node_0<void *> c0;
node_0<void *> c1;
node_0<void *> c2;
node_0<void *> c3;
leaf_node<int> c0(nullptr);
leaf_node<int> c1(nullptr);
leaf_node<int> c2(nullptr);
leaf_node<int> c3(nullptr);

n.set_child(-128, &c0);
n.set_child(-43, &c1);
Expand Down
24 changes: 12 additions & 12 deletions bench/node_48.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ PICOBENCH_SUITE("node_48");

static void node_48_constructor(state &s) {
for (auto _ : s) {
node_48<void *> n;
node_48<int> n;
}
}
PICOBENCH(node_48_constructor);

static void node_48_find_child(state &s) {
node_48<void *> n;
node_0<void *> child;
node_48<int> n;
leaf_node<int> child(nullptr);
for (int i = 0; i < 48; ++i) {
n.set_child(std::floor(5.4468 * i) - 128, &child);
}
Expand All @@ -32,12 +32,12 @@ static void node_48_find_child(state &s) {
PICOBENCH(node_48_find_child);

static void node_48_set_child(state &s) {
node_48<void *> *n = new node_48<void *>();
node_0<void *> child;
node_48<int> *n = new node_48<int>();
leaf_node<int> child(nullptr);
for (auto _ : s) {
if (n->is_full()) {
delete n;
n = new node_48<void *>();
n = new node_48<int>();
}
n->set_child((rand() % 256) - 128, &child);
}
Expand All @@ -46,16 +46,16 @@ PICOBENCH(node_48_set_child);

static void node_48_grow(state &s) {
for (auto _ : s) {
node_48<void *> *n = new node_48<void *>();
node<void *> *new_n = n->grow();
node_48<int> *n = new node_48<int>();
node<int> *new_n = n->grow();
delete new_n;
}
}
PICOBENCH(node_48_grow);

static void node_48_next_partial_key(state &s) {
node_48<void *> n;
node_0<void *> child;
node_48<int> n;
leaf_node<int> child(nullptr);
for (int i = 0; i < 48; ++i) {
n.set_child(std::floor(5.4468 * i) - 128, &child);
}
Expand All @@ -66,8 +66,8 @@ static void node_48_next_partial_key(state &s) {
PICOBENCH(node_48_next_partial_key);

static void node_48_prev_partial_key(state &s) {
node_48<void *> n;
node_0<void *> child;
node_48<int> n;
leaf_node<int> child(nullptr);
for (int i = 0; i < 48; ++i) {
n.set_child(std::floor(5.4468 * i) - 128, &child);
}
Expand Down
3 changes: 2 additions & 1 deletion include/art.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

#include "art/art.hpp"
#include "art/child_it.hpp"
#include "art/inner_node.hpp"
#include "art/leaf_node.hpp"
#include "art/node.hpp"
#include "art/node_0.hpp"
#include "art/node_16.hpp"
#include "art/node_256.hpp"
#include "art/node_4.hpp"
Expand Down
Loading

0 comments on commit 01b6a4e

Please sign in to comment.