forked from MassiveAtoms/hashmap-bench
Some documentation
This commit is contained in:
@@ -4,13 +4,23 @@
|
||||
#include <fstream>
|
||||
#include "./tests.h"
|
||||
|
||||
// sizes that will be tested
|
||||
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
|
||||
};
|
||||
// to print type info
|
||||
|
||||
|
||||
|
||||
/*
|
||||
to print typenames
|
||||
for more info, see
|
||||
https://stackoverflow.com/a/20170989
|
||||
and
|
||||
https://stackoverflow.com/a/56766138
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
constexpr auto type_name() {
|
||||
@@ -39,6 +49,17 @@ std::basic_string_view<char> name(T var) {
|
||||
return type_name<decltype(var)>();
|
||||
}
|
||||
|
||||
/*
|
||||
This is the function that outputs the results to a file.
|
||||
it calls int_test (n_run) times for all sizes < maxsize, and then append the
|
||||
results to the outputfile.
|
||||
We use a template function to massively reduce the ammount of code needed.
|
||||
Instead of writing 17 different functions for all different hashmaps, we can
|
||||
do this. The compiler will then see that a call is made where the map is of type
|
||||
std::unordered_map, for example, and then generate the function where T is
|
||||
replaced with std::unordered_map. Well, that's the simple explanation,
|
||||
more info at https://en.cppreference.com/w/cpp/language/templates
|
||||
*/
|
||||
|
||||
template<class T>
|
||||
void int_test_aggregate(T map, int runs, int maxsize=20000000) {
|
||||
@@ -71,7 +92,10 @@ void int_test_aggregate(T map, int runs, int maxsize=20000000) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
This is pretty much the same function, but it calls string_test instead of
|
||||
int_test. More info on why we needed to split this, can be seen in tests.h
|
||||
*/
|
||||
template<class T>
|
||||
void string_test_aggregate(T map, int runs, int maxsize=20000000) {
|
||||
std::ofstream output{"results.csv", std::ios_base::app};
|
||||
|
Reference in New Issue
Block a user