for real this time
This commit is contained in:
@@ -4,13 +4,14 @@
|
||||
#include "./tests.h"
|
||||
#include <ostream>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
|
||||
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
|
||||
};
|
||||
// to print type info
|
||||
|
||||
@@ -46,7 +47,7 @@ std::basic_string_view<char> name(T var){
|
||||
template<class T>
|
||||
void int_test_aggregate(T map, int runs){
|
||||
std::ofstream output{"results.csv", std::ios_base::app};
|
||||
for (int i = 0; i < runs; ++i);
|
||||
for (int i = 0; i < runs; ++i){
|
||||
string insert = "\nint_insert, '";
|
||||
string succ_lookup = "\nint_succ_lookup, '";
|
||||
string nosucc_lookup = "\nint_nosucc_lookup, '";
|
||||
@@ -57,7 +58,7 @@ void int_test_aggregate(T map, int runs){
|
||||
nosucc_lookup += string{name(map)} +"'" ;
|
||||
delet += string{name(map)} + "'" ;
|
||||
for ( auto size : sizes){
|
||||
vector<float> results = int_test(map, size);
|
||||
vector<int> results = int_test(map, size);
|
||||
|
||||
insert += ", " + std::to_string(results[0]);
|
||||
succ_lookup += ", " + std::to_string(results[1]);
|
||||
@@ -67,6 +68,8 @@ void int_test_aggregate(T map, int runs){
|
||||
output << insert << succ_lookup << nosucc_lookup << delet;
|
||||
cout << insert << succ_lookup << nosucc_lookup << delet;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +77,7 @@ void int_test_aggregate(T map, int runs){
|
||||
template<class T>
|
||||
void string_test_aggregate(T map, int runs){
|
||||
std::ofstream output{"results.csv", std::ios_base::app};
|
||||
for (int i = 0; i < runs; ++i);
|
||||
for (int i = 0; i < runs; ++i){
|
||||
string insert = "\nint_insert, '";
|
||||
string succ_lookup = "\nint_succ_lookup, '";
|
||||
string nosucc_lookup = "\nint_nosucc_lookup, '";
|
||||
@@ -85,16 +88,17 @@ void string_test_aggregate(T map, int runs){
|
||||
nosucc_lookup += string{name(map)} +"'" ;
|
||||
delet += string{name(map)} + "'" ;
|
||||
for ( auto size : sizes){
|
||||
vector<float> results = string_test(map, size);
|
||||
vector<int> results = string_test(map, size);
|
||||
|
||||
insert += ", " + std::to_string(results[0]);
|
||||
succ_lookup += ", " + std::to_string(results[1]);
|
||||
nosucc_lookup +=", " + std::to_string(results[2]);
|
||||
delet += ", " + std::to_string(results[3]);
|
||||
std::this_thread::sleep_for(seconds(5));
|
||||
}
|
||||
output << insert << succ_lookup << nosucc_lookup << delet;
|
||||
cout << insert << succ_lookup << nosucc_lookup << delet;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user