-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include <benchmark/benchmark.h> | ||
#include <boost/heap/fibonacci_heap.hpp> | ||
#include <lb/tcp/selectors.hpp> | ||
|
||
|
||
struct CounterWrapper { | ||
lb::tcp::Backend* b; | ||
std::size_t counter = 0; | ||
std::size_t id = 0; | ||
}; | ||
|
||
struct ConnectionsCompare { | ||
bool operator()(const CounterWrapper& lhs, const CounterWrapper& rhs) const | ||
{ | ||
return lhs.counter > rhs.counter; | ||
} | ||
}; | ||
|
||
static void BenchmarkFibbanaciHeap(benchmark::State& state) | ||
{ | ||
for (auto _ : state) | ||
{ | ||
boost::heap::fibonacci_heap<CounterWrapper, boost::heap::compare<ConnectionsCompare>> heap; | ||
auto handle1 = heap.push({nullptr, 0, 1}); | ||
auto handle2 = heap.push({nullptr, 0, 2}); | ||
(*handle1).counter++; | ||
heap.increase(handle1); | ||
heap.erase(handle2); | ||
heap.erase(handle1); | ||
} | ||
} | ||
|
||
BENCHMARK(BenchmarkFibbanaciHeap); | ||
|
||
static void BenchmarkPairingHeap(benchmark::State& state) | ||
{ | ||
for (auto _ : state) | ||
{ | ||
boost::heap::pairing_heap<CounterWrapper, boost::heap::compare<ConnectionsCompare>> heap; | ||
auto handle1 = heap.push({nullptr, 0, 1}); | ||
auto handle2 = heap.push({nullptr, 0, 2}); | ||
(*handle1).counter++; | ||
heap.increase(handle1); | ||
heap.erase(handle2); | ||
heap.erase(handle1); | ||
} | ||
} | ||
|
||
BENCHMARK(BenchmarkPairingHeap); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ spdlog/1.13.0 | |
jemalloc/5.3.0 | ||
ctre/3.8.1 | ||
gtest/1.14.0 | ||
benchmark/1.8.3 | ||
|
||
[generators] | ||
CMakeDeps | ||
|