|
| 1 | + |
| 2 | +#include "CLUEstering/CLUEstering.hpp" |
| 3 | +#include "utils/generation.hpp" |
| 4 | +#include <benchmark/benchmark.h> |
| 5 | + |
| 6 | +#include <algorithm> |
| 7 | +#include <cstddef> |
| 8 | +#include <iterator> |
| 9 | +#include <ranges> |
| 10 | +#include <vector> |
| 11 | + |
| 12 | +static void BM_SingleEvents(benchmark::State& state) { |
| 13 | + for (auto _ : state) { |
| 14 | + state.PauseTiming(); |
| 15 | + auto queue = clue::get_queue(0u); |
| 16 | + |
| 17 | + std::vector<clue::PointsHost<2>> host_points; |
| 18 | + std::ranges::transform(std::views::iota(0u) | std::views::take(1000), |
| 19 | + std::back_inserter(host_points), |
| 20 | + [&](const auto i) { |
| 21 | + return clue::read_csv<2>( |
| 22 | + queue, "../../data/small_event_" + std::to_string(i) + ".csv"); |
| 23 | + }); |
| 24 | + auto i = 0; |
| 25 | + for (auto& h_points : host_points) { |
| 26 | + clue::PointsDevice<2> d_points(queue, h_points.size()); |
| 27 | + const auto dc = 1.5f, rhoc = 10.f, outlier = 1.5f; |
| 28 | + state.ResumeTiming(); |
| 29 | + |
| 30 | + clue::Clusterer<2> algo(queue, dc, rhoc, outlier); |
| 31 | + algo.make_clusters(queue, h_points, d_points); |
| 32 | + } |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | +static void BM_Batched(benchmark::State& state) { |
| 37 | + for (auto _ : state) { |
| 38 | + state.PauseTiming(); |
| 39 | + auto queue = clue::get_queue(0u); |
| 40 | + |
| 41 | + clue::PointsHost<2> h_points = clue::read_csv<2>(queue, "../../data/small_events_batch.csv"); |
| 42 | + const size_t n_points = h_points.size(); |
| 43 | + clue::PointsDevice<2> d_points(queue, n_points); |
| 44 | + const auto dc = 1.5f, rhoc = 10.f, outlier = 1.5f; |
| 45 | + std::vector<std::size_t> batch_event_sizes(1000, n_points / 1000); |
| 46 | + state.ResumeTiming(); |
| 47 | + |
| 48 | + clue::Clusterer<2> algo(queue, dc, rhoc, outlier); |
| 49 | + algo.make_clusters(queue, h_points, d_points, batch_event_sizes); |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +BENCHMARK(BM_SingleEvents)->Iterations(1); |
| 54 | +BENCHMARK(BM_Batched)->Iterations(1); |
| 55 | +BENCHMARK_MAIN(); |
0 commit comments