for real this time

This commit is contained in:
TinyAtoms
2020-02-05 14:15:02 -03:00
parent 64adaa9be1
commit 904e2d1c0b
5 changed files with 53 additions and 14 deletions

View File

@@ -35,8 +35,8 @@ void prepare(google::sparse_hash_map<int, int>& map, int size){
}
template <class T>
vector<float> int_test(T testmap, int size){
vector<float> results; // insert, lookup, unsuccesful lookup, delete times
vector<int> int_test(T testmap, int size){
vector<int> results; // insert, lookup, unsuccesful lookup, delete times
vector<int> sample_keys; // get a sample of keys to lookup and later delete
// unsuccesful lookup keys
@@ -113,6 +113,7 @@ vector<float> int_test(T testmap, int size){
time_point<steady_clock> delete_end = steady_clock::now();
auto delete_time = (duration_cast<nanoseconds>(delete_end - delete_start) - vector_acces_time) / 10000;
results.push_back(delete_time.count());
testmap.clear();
return results;
}
@@ -122,8 +123,8 @@ vector<float> int_test(T testmap, int size){
template <class T>
vector<float> string_test(T map, int size){
vector<float> results; // insert, lookup, unsuccesful lookup, delete times
vector<int> string_test(T map, int size){
vector<int> results; // insert, lookup, unsuccesful lookup, delete times
vector<string> sample_keys; // get a sample of keys to lookup and later delete
// unsuccesful lookup keys
@@ -182,7 +183,7 @@ vector<float> string_test(T map, int size){
// unsuccesful lookup test
time_point<steady_clock> unlookup_start = steady_clock::now();
for (auto key : nonkeys){
if (testmap[key] == "") cout << "WTF";
if (testmap[key] == "a") cout << "WTF";
}
time_point<steady_clock> unlookup_end = steady_clock::now();
auto unlookup_time = (duration_cast<nanoseconds>(unlookup_end - unlookup_start) - vector_acces_time) / 10000 ;
@@ -199,6 +200,7 @@ vector<float> string_test(T map, int size){
time_point<steady_clock> delete_end = steady_clock::now();
auto delete_time = (duration_cast<nanoseconds>(delete_end - delete_start) - vector_acces_time) / 10000;
results.push_back(delete_time.count());
testmap.clear();
return results;
}