Loading test_map.hpp +10 −18 Original line number Diff line number Diff line Loading @@ -7,13 +7,6 @@ #include <vector> #ifdef HAVE_CUDA #include <TNL/Devices/Cuda.h> using Device = TNL::Devices::Cuda; #else #include <TNL/Devices/Host.h> using Device = TNL::Devices::Host; #endif namespace TestMap { double g_results[6][4]; Loading Loading @@ -96,7 +89,6 @@ M<K, V, Device> test_building(const PairArray<K, V>& pairs) { template<template<typename, typename, class> class M, typename K, typename V> void test_correct_query(const M<K, V, Device>& table, const PairArray<K, V>& pairs, const CpuPairs<K, V>& cpuPairs, int nQueries) { BEGIN_TEST(CORRECT QUERY) Loading @@ -123,7 +115,6 @@ T ruin(const T& value); template<template<typename, typename, class> class M, typename K, typename V> void test_wrong_query(const M<K, V, Device>& table, const PairArray<K, V>& pairs, const CpuPairs<K, V>& cpuPairs, int nQueries) { BEGIN_TEST(WRONG QUERY) Loading Loading @@ -189,8 +180,8 @@ void test(const char* fileName) { std::vector<Pair<K, V>> cpuPairs; auto pairs = read_data<K, V>(fileName, cpuPairs); auto table = test_building<M, K, V>(pairs); test_correct_query<M, K, V>(table, pairs, cpuPairs, pairs.getSize()); test_wrong_query<M, K, V>(table, pairs, cpuPairs, pairs.getSize()); test_correct_query<M, K, V>(table, cpuPairs, pairs.getSize()); test_wrong_query<M, K, V>(table, cpuPairs, pairs.getSize()); test_random<M, K, V>(pairs, cpuPairs, 100000, 0.5); g_row++; Loading @@ -202,23 +193,25 @@ std::string ruin<std::string>(const std::string& value) { return "WRONG_" + value; } /*template<> PairArray<std::string, std::string> read_data(const char* fileName) { template<> PairArray<std::string, std::string> read_data(const char* fileName, CpuPairs<std::string, std::string>& cpuPairs) { std::ifstream dataFile(fileName); int nLines = std::count(std::istreambuf_iterator<char>(dataFile), std::istreambuf_iterator<char>(), '\n'); PairArray<std::string, std::string> lines(nLines); std::string line; dataFile.seekg(0); for (int i = 0; i < nLines; i++) { std::getline(dataFile, line); std::istringstream iss(line); std::string key, value; std::getline(iss, key, ':'); std::getline(iss, value); lines[i] = {key, value}; lines.setElement(i, {key, value}); cpuPairs.push_back({key, value}); } return lines; }*/ } template<> Coordinates3D ruin<Coordinates3D>(const Coordinates3D& value) { Loading Loading @@ -255,11 +248,10 @@ PairArray<Coordinates3D, int> read_data(const char* fileName, CpuPairs<Coordinat template<template<typename, typename, class> class M> void test_class(const std::string className) { //std::cerr << "Testing " << className << "<std::string, std::string>:" << std::endl; //test<M, std::string, std::string>("data/cities.txt", {"", ""}); //test<M, std::string, std::string>("data/cities.txt"); std::cerr << "Testing " << className << "<TNL::Containers::StaticArray<3, int>, int>:" << std::endl; test<M, Coordinates3D, int>("data/coordinates.txt"); //test<M, Coordinates3D, int>("data/crd1.txt", {{0, 0, 0}, 0}); } Loading @@ -284,7 +276,7 @@ void print_results_table() { void run() { test_class<CuckooHashMap>("CuckooHashMap"); //test_class<HashGraphV1Map>("HashGraphV1Map"); test_class<HashGraphV1Map>("HashGraphV1Map"); //test_class<StdMapWrapper>("std::map"); print_results_table(); Loading Loading
test_map.hpp +10 −18 Original line number Diff line number Diff line Loading @@ -7,13 +7,6 @@ #include <vector> #ifdef HAVE_CUDA #include <TNL/Devices/Cuda.h> using Device = TNL::Devices::Cuda; #else #include <TNL/Devices/Host.h> using Device = TNL::Devices::Host; #endif namespace TestMap { double g_results[6][4]; Loading Loading @@ -96,7 +89,6 @@ M<K, V, Device> test_building(const PairArray<K, V>& pairs) { template<template<typename, typename, class> class M, typename K, typename V> void test_correct_query(const M<K, V, Device>& table, const PairArray<K, V>& pairs, const CpuPairs<K, V>& cpuPairs, int nQueries) { BEGIN_TEST(CORRECT QUERY) Loading @@ -123,7 +115,6 @@ T ruin(const T& value); template<template<typename, typename, class> class M, typename K, typename V> void test_wrong_query(const M<K, V, Device>& table, const PairArray<K, V>& pairs, const CpuPairs<K, V>& cpuPairs, int nQueries) { BEGIN_TEST(WRONG QUERY) Loading Loading @@ -189,8 +180,8 @@ void test(const char* fileName) { std::vector<Pair<K, V>> cpuPairs; auto pairs = read_data<K, V>(fileName, cpuPairs); auto table = test_building<M, K, V>(pairs); test_correct_query<M, K, V>(table, pairs, cpuPairs, pairs.getSize()); test_wrong_query<M, K, V>(table, pairs, cpuPairs, pairs.getSize()); test_correct_query<M, K, V>(table, cpuPairs, pairs.getSize()); test_wrong_query<M, K, V>(table, cpuPairs, pairs.getSize()); test_random<M, K, V>(pairs, cpuPairs, 100000, 0.5); g_row++; Loading @@ -202,23 +193,25 @@ std::string ruin<std::string>(const std::string& value) { return "WRONG_" + value; } /*template<> PairArray<std::string, std::string> read_data(const char* fileName) { template<> PairArray<std::string, std::string> read_data(const char* fileName, CpuPairs<std::string, std::string>& cpuPairs) { std::ifstream dataFile(fileName); int nLines = std::count(std::istreambuf_iterator<char>(dataFile), std::istreambuf_iterator<char>(), '\n'); PairArray<std::string, std::string> lines(nLines); std::string line; dataFile.seekg(0); for (int i = 0; i < nLines; i++) { std::getline(dataFile, line); std::istringstream iss(line); std::string key, value; std::getline(iss, key, ':'); std::getline(iss, value); lines[i] = {key, value}; lines.setElement(i, {key, value}); cpuPairs.push_back({key, value}); } return lines; }*/ } template<> Coordinates3D ruin<Coordinates3D>(const Coordinates3D& value) { Loading Loading @@ -255,11 +248,10 @@ PairArray<Coordinates3D, int> read_data(const char* fileName, CpuPairs<Coordinat template<template<typename, typename, class> class M> void test_class(const std::string className) { //std::cerr << "Testing " << className << "<std::string, std::string>:" << std::endl; //test<M, std::string, std::string>("data/cities.txt", {"", ""}); //test<M, std::string, std::string>("data/cities.txt"); std::cerr << "Testing " << className << "<TNL::Containers::StaticArray<3, int>, int>:" << std::endl; test<M, Coordinates3D, int>("data/coordinates.txt"); //test<M, Coordinates3D, int>("data/crd1.txt", {{0, 0, 0}, 0}); } Loading @@ -284,7 +276,7 @@ void print_results_table() { void run() { test_class<CuckooHashMap>("CuckooHashMap"); //test_class<HashGraphV1Map>("HashGraphV1Map"); test_class<HashGraphV1Map>("HashGraphV1Map"); //test_class<StdMapWrapper>("std::map"); print_results_table(); Loading