forked from MassiveAtoms/hashmap-bench
made it use less memory
This commit is contained in:
@@ -10,7 +10,7 @@ std::vector<int> sizes = {
|
||||
50000, 100000, 150000, 200000, 250000, 300000, 350000, 400000, 500000,
|
||||
600000, 700000, 800000, 900000, 1000000,
|
||||
2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000,
|
||||
15000000, 20000000, 25000000, 30000000, 35000000, 40000000, 45000000, 50000000
|
||||
// 15000000, 20000000, 25000000, 30000000, 35000000, 40000000, 45000000, 50000000
|
||||
};
|
||||
|
||||
|
||||
@@ -47,18 +47,19 @@ std::basic_string_view<char> name(T var){
|
||||
|
||||
template<class T>
|
||||
int int_test(T map, int repeats=30){
|
||||
std::cout << "\t\t" << name(map) << "int tests \n";
|
||||
std::ofstream output{"results.csv", std::ios_base::app};
|
||||
// insert int tests
|
||||
for (int i = 0; i < repeats; ++i){
|
||||
std::string resultline = "insert_int, '" + std::string{name(map)} + "', ";
|
||||
for (auto size: sizes){
|
||||
std::cout << size << ", ";
|
||||
float result = insert_int_test(size, T{}).count();
|
||||
resultline += std::to_string(result);
|
||||
resultline += ", ";
|
||||
}
|
||||
output << resultline << "\n";
|
||||
}
|
||||
std::cout << "insert int test done\n";
|
||||
|
||||
// lookup int
|
||||
for (int i = 0; i < repeats; ++i){
|
||||
@@ -70,6 +71,7 @@ int int_test(T map, int repeats=30){
|
||||
}
|
||||
output << resultline << "\n";
|
||||
}
|
||||
std::cout << "lookup int test done\n";
|
||||
// unsuccesful lookup
|
||||
for (int i = 0; i < repeats; ++i){
|
||||
std::string resultline = "nolookup_int, '" + std::string{name(map)} + "', ";
|
||||
@@ -80,6 +82,7 @@ int int_test(T map, int repeats=30){
|
||||
}
|
||||
output << resultline << "\n";
|
||||
}
|
||||
std::cout << "unsuccesful lookup int test done\n";
|
||||
|
||||
// deletion
|
||||
for (int i = 0; i < repeats; ++i){
|
||||
@@ -91,13 +94,14 @@ int int_test(T map, int repeats=30){
|
||||
}
|
||||
output << resultline << "\n";
|
||||
}
|
||||
|
||||
std::cout << "deletion int test done\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
int string_test(T map, int repeats=30){
|
||||
std::cout <<"\t\t" << name(map) << " stringtest \n";
|
||||
std::ofstream output{"results.csv", std::ios_base::app};
|
||||
// insert int tests
|
||||
for (int i = 0; i < repeats; ++i){
|
||||
@@ -109,6 +113,7 @@ int string_test(T map, int repeats=30){
|
||||
}
|
||||
output << resultline << "\n";
|
||||
}
|
||||
std::cout << "insert string test done\n";
|
||||
|
||||
// lookup int
|
||||
for (int i = 0; i < repeats; ++i){
|
||||
@@ -120,6 +125,7 @@ int string_test(T map, int repeats=30){
|
||||
}
|
||||
output << resultline << "\n";
|
||||
}
|
||||
std::cout << "lookup string test done\n";
|
||||
// unsuccesful lookup
|
||||
for (int i = 0; i < repeats; ++i){
|
||||
std::string resultline = "nolookup_string, '" + std::string{name(map)} + "', ";
|
||||
@@ -130,7 +136,7 @@ int string_test(T map, int repeats=30){
|
||||
}
|
||||
output << resultline << "\n";
|
||||
}
|
||||
|
||||
std::cout << "unsuccesful lookup string test done\n";
|
||||
// deletion
|
||||
for (int i = 0; i < repeats; ++i){
|
||||
std::string resultline = "delete_string, '" + std::string{name(map)} + "', ";
|
||||
@@ -141,6 +147,7 @@ int string_test(T map, int repeats=30){
|
||||
}
|
||||
output << resultline << "\n";
|
||||
}
|
||||
std::cout << "deletion string test done\n";
|
||||
|
||||
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user