Commit 2e4a02f1 authored by sevenuz's avatar sevenuz
Browse files

test for rapidhash, benchmark for rapidhash and simple hash

parent 71b81b49
Loading
Loading
Loading
Loading
Loading
+45 −0
Original line number Diff line number Diff line
/*
  Copyright 2018-2024, Barcelona Supercomputing Center (BSC), Spain
  Copyright 2015-2024, Johannes Gutenberg Universitaet Mainz, Germany

  This software was partially supported by the
  EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu).

  This software was partially supported by the
  ADA-FS project under the SPPEXA project funded by the DFG.

  SPDX-License-Identifier: MIT
*/

#include <catch2/catch_all.hpp>
#include <ctime>
#include <fmt/format.h>
#include <common/rpc/distributor.hpp>

#define NUM_ITERATIONS 10000000

TEST_CASE("Distributor Testing", "[Distributor]") {
    GIVEN("Standard distributor") {
        auto d = gkfs::rpc::SimpleHashDistributor();

        REQUIRE(d.locate_data("/t.c01", 1, 3, 0) == 2);
        REQUIRE(d.locate_data("/t.c01", 2, 3, 0) == 0);
        REQUIRE(d.locate_data("/t.c01", 3, 3, 0) == 2);

        BENCHMARK("Simple hash benchmark") {
            return d.locate_data("/dadf", 3, 3, 0);
        };
    }

    GIVEN("Rapid hash distributor") {
        auto d = gkfs::rpc::RapidHashDistributor();

        REQUIRE(d.locate_data("/t.c01", 1, 3, 0) == 2);
        REQUIRE(d.locate_data("/t.c01", 2, 3, 0) == 0);
        REQUIRE(d.locate_data("/t.c01", 3, 3, 0) == 1);

        BENCHMARK("RapidHash benchmark") {
            return d.locate_data("/dadf", 3, 3, 0);
        };
    }
}