about summary refs log tree commit diff stats
path: root/archive/2025/summer/bsc_karidas/benchmarks/BenchmarkUtils.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'archive/2025/summer/bsc_karidas/benchmarks/BenchmarkUtils.hpp')
-rw-r--r--archive/2025/summer/bsc_karidas/benchmarks/BenchmarkUtils.hpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/archive/2025/summer/bsc_karidas/benchmarks/BenchmarkUtils.hpp b/archive/2025/summer/bsc_karidas/benchmarks/BenchmarkUtils.hpp
new file mode 100644
index 000000000..ec94d89ce
--- /dev/null
+++ b/archive/2025/summer/bsc_karidas/benchmarks/BenchmarkUtils.hpp
@@ -0,0 +1,79 @@
+#ifndef BENCHMARK_UTILS_HPP
+#define BENCHMARK_UTILS_HPP
+
+#include "LoggingManager.hpp"
+#include <vector>
+#include <string>
+#include <optional>
+#include <filesystem>
+#include <iostream>
+#include <chrono>
+#include <algorithm>
+#include <random>
+#include <numeric>
+
+using BatchWithDestination = std::pair<std::vector<LogEntry>, std::optional<std::string>>;
+
+class LatencyCollector
+{
+private:
+    std::vector<std::chrono::nanoseconds> latencies;
+
+public:
+    void addMeasurement(std::chrono::nanoseconds latency)
+    {
+        latencies.push_back(latency);
+    }
+
+    void reserve(size_t capacity)
+    {
+        latencies.reserve(capacity);
+    }
+
+    const std::vector<std::chrono::nanoseconds> &getMeasurements() const
+    {
+        return latencies;
+    }
+
+    void clear()
+    {
+        latencies.clear();
+    }
+
+    // Merge another collector's measurements into this one
+    void merge(const LatencyCollector &other)
+    {
+        const auto &otherLatencies = other.getMeasurements();
+        latencies.insert(latencies.end(), otherLatencies.begin(), otherLatencies.end());
+    }
+};
+
+struct LatencyStats
+{
+    double maxMs;
+    double avgMs;
+    double medianMs;
+    size_t count;
+};
+
+// Function to calculate statistics from a merged collector
+LatencyStats calculateLatencyStats(const LatencyCollector &collector);
+
+// Modified to return latency measurements instead of using global state
+LatencyCollector appendLogEntries(LoggingManager &loggingManager, const std::vector<BatchWithDestination> &batches);
+
+void cleanupLogDirectory(const std::string &logDir);
+
+size_t calculateTotalDataSize(const std::vector<BatchWithDestination> &batches, int numProducers);
+
+size_t calculateDirectorySize(const std::string &dirPath);
+
+std::vector<BatchWithDestination> generateBatches(
+    int numEntries,
+    int numSpecificFiles,
+    int batchSize,
+    int payloadSize);
+
+void printLatencyStats(const LatencyStats &stats);
+
+#endif
\ No newline at end of file