this is the most up to date working #2

Merged
MassiveAtoms merged 26 commits from moretables into master 2020-04-17 16:47:27 +00:00
5 changed files with 53 additions and 14 deletions
Showing only changes of commit 904e2d1c0b - Show all commits

View File

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.15)
project(another_studproject)
set(CMAKE_CXX_STANDARD 17)
# set(CMAKE_CXX_FLAGS "-O3 -flto=thin -march=native")
set(CMAKE_CXX_FLAGS "-O3 -flto=thin -march=native")
add_executable(another_studproject
./src/includes/generator.h
./src/generator.cpp

View File

@ -18,8 +18,8 @@ typedef std::unordered_map<string, string> stringmap;
int main() {
time_point<steady_clock> start_test = steady_clock::now();
// string_test(stringmap{}, 1); // process gets killed for sizes >35000
int_test_aggregate(intmap{}, 2);
string_test_aggregate(stringmap{}, 2);
int_test_aggregate(intmap{}, 1);
string_test_aggregate(stringmap{}, 1);
time_point<steady_clock> end_test = steady_clock::now();
std::cout << "1 run all tests 1 map: " << duration_cast<minutes>(end_test-start_test).count() << " minutes";
// test takes 52 mins for 10 runs for one hashmap

View File

@ -0,0 +1,33 @@
int_insert, 'std::unordered_map<int, int>', 554, 591, 503, 498, 512, 526, 560, 564, 580
int_succ_lookup, 'std::unordered_map<int, int>', 435, 292, 312, 334, 354, 362, 383, 398, 413
int_nosucc_lookup, 'std::unordered_map<int, int>', 1571, 1800, 2700, 3538, 4559, 567, 6292, 596, 606
int_delete, 'std::unordered_map<int, int>', 428, 415, 461, 500, 510, 557, 561, 605, 615
int_insert, 'std::unordered_map<int, int>', 629, 459, 527, 498, 562, 541, 558, 557, 557
int_succ_lookup, 'std::unordered_map<int, int>', 404, 288, 342, 336, 357, 376, 396, 388, 392
int_nosucc_lookup, 'std::unordered_map<int, int>', 1608, 2003, 2863, 3699, 4624, 576, 6560, 586, 599
int_delete, 'std::unordered_map<int, int>', 532, 482, 479, 538, 519, 588, 587, 582, 591
int_insert, 'std::unordered_map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >', 636, 644, 667, 728, 737, 727, 752, 750, 749
int_succ_lookup, 'std::unordered_map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >', 432, 457, 472, 504, 506, 505, 537, 530, 519
int_nosucc_lookup, 'std::unordered_map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >', 1139, 1675, 2395, 2933, 3777, 650, 4953, 660, 661
int_delete, 'std::unordered_map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >', 762, 616, 648, 697, 693, 699, 736, 715, 713
int_insert, 'std::unordered_map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >', 706, 696, 865, 841, 689, 687, 716, 709, 721
int_succ_lookup, 'std::unordered_map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >', 582, 485, 799, 685, 495, 500, 537, 534, 518
int_nosucc_lookup, 'std::unordered_map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >', 1124, 1752, 3944, 3627, 3532, 601, 5333, 620, 628
int_delete, 'std::unordered_map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >', 672, 632, 1036, 797, 691, 691, 819, 727, 722
int_insert, 'std::unordered_map<int, int>', 138, 358, 194, 221, 228, 236, 257, 263, 262
int_succ_lookup, 'std::unordered_map<int, int>', 65, 202, 94, 107, 135, 114, 121, 120, 122
int_nosucc_lookup, 'std::unordered_map<int, int>', 358, 1158, 1226, 1606, 2330, 250, 2889, 306, 263
int_delete, 'std::unordered_map<int, int>', 166, 304, 229, 263, 282, 290, 310, 330, 328
int_insert, 'std::unordered_map<int, int>', 87, 240, 248, 218, 228, 241, 259, 254, 264
int_succ_lookup, 'std::unordered_map<int, int>', 37, 196, 101, 107, 114, 137, 136, 125, 124
int_nosucc_lookup, 'std::unordered_map<int, int>', 233, 885, 1243, 1595, 2097, 241, 4238, 265, 267
int_delete, 'std::unordered_map<int, int>', 95, 228, 256, 270, 287, 310, 571, 303, 351
int_insert, 'std::unordered_map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >', 591, 534, 307, 370, 382, 382, 399, 405, 409
int_succ_lookup, 'std::unordered_map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >', 189, 225, 264, 285, 287, 291, 302, 301, 308
int_nosucc_lookup, 'std::unordered_map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >', 568, 2173, 1793, 2297, 2845, 376, 3789, 388, 384
int_delete, 'std::unordered_map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >', 243, 828, 342, 365, 373, 375, 388, 386, 394
int_insert, 'std::unordered_map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >', 350, 290, 296, 501, 942, 349, 340, 346, 355
int_succ_lookup, 'std::unordered_map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >', 180, 237, 249, 385, 476, 289, 283, 288, 291
int_nosucc_lookup, 'std::unordered_map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >', 665, 1202, 1745, 3419, 4709, 321, 3521, 332, 350
int_delete, 'std::unordered_map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >', 246, 310, 322, 457, 1076, 353, 371, 373, 386
1 insert_string int_insert 'std::unordered_map<std::__cxx11::basic_string<char> 'std::unordered_map<int std::__cxx11::basic_string<char> >' int>' 407.000000 554 345.000000 591 325.000000 503 402.000000 498 475.000000 512 378.000000 526 476.000000 560 553.000000 564 369.000000 580
1 int_insert 'std::unordered_map<int int>' 554 591 503 498 512 526 560 564 580
2 int_succ_lookup 'std::unordered_map<int int>' 435 292 312 334 354 362 383 398 413
3 int_nosucc_lookup 'std::unordered_map<int int>' 1571 1800 2700 3538 4559 567 6292 596 606
4 int_delete 'std::unordered_map<int int>' 428 415 461 500 510 557 561 605 615
5 int_insert 'std::unordered_map<int int>' 629 459 527 498 562 541 558 557 557
6 int_succ_lookup 'std::unordered_map<int int>' 404 288 342 336 357 376 396 388 392
7 int_nosucc_lookup 'std::unordered_map<int int>' 1608 2003 2863 3699 4624 576 6560 586 599
8 int_delete 'std::unordered_map<int int>' 532 482 479 538 519 588 587 582 591
9 int_insert 'std::unordered_map<std::__cxx11::basic_string<char> std::__cxx11::basic_string<char> >' 636 644 667 728 737 727 752 750 749
10 int_succ_lookup 'std::unordered_map<std::__cxx11::basic_string<char> std::__cxx11::basic_string<char> >' 432 457 472 504 506 505 537 530 519
11 int_nosucc_lookup 'std::unordered_map<std::__cxx11::basic_string<char> std::__cxx11::basic_string<char> >' 1139 1675 2395 2933 3777 650 4953 660 661
12 int_delete 'std::unordered_map<std::__cxx11::basic_string<char> std::__cxx11::basic_string<char> >' 762 616 648 697 693 699 736 715 713
13 int_insert 'std::unordered_map<std::__cxx11::basic_string<char> std::__cxx11::basic_string<char> >' 706 696 865 841 689 687 716 709 721
14 int_succ_lookup 'std::unordered_map<std::__cxx11::basic_string<char> std::__cxx11::basic_string<char> >' 582 485 799 685 495 500 537 534 518
15 int_nosucc_lookup 'std::unordered_map<std::__cxx11::basic_string<char> std::__cxx11::basic_string<char> >' 1124 1752 3944 3627 3532 601 5333 620 628
16 int_delete 'std::unordered_map<std::__cxx11::basic_string<char> std::__cxx11::basic_string<char> >' 672 632 1036 797 691 691 819 727 722
17 int_insert 'std::unordered_map<int int>' 138 358 194 221 228 236 257 263 262
18 int_succ_lookup 'std::unordered_map<int int>' 65 202 94 107 135 114 121 120 122
19 int_nosucc_lookup 'std::unordered_map<int int>' 358 1158 1226 1606 2330 250 2889 306 263
20 int_delete 'std::unordered_map<int int>' 166 304 229 263 282 290 310 330 328
21 int_insert 'std::unordered_map<int int>' 87 240 248 218 228 241 259 254 264
22 int_succ_lookup 'std::unordered_map<int int>' 37 196 101 107 114 137 136 125 124
23 int_nosucc_lookup 'std::unordered_map<int int>' 233 885 1243 1595 2097 241 4238 265 267
24 int_delete 'std::unordered_map<int int>' 95 228 256 270 287 310 571 303 351
25 int_insert 'std::unordered_map<std::__cxx11::basic_string<char> std::__cxx11::basic_string<char> >' 591 534 307 370 382 382 399 405 409
26 int_succ_lookup 'std::unordered_map<std::__cxx11::basic_string<char> std::__cxx11::basic_string<char> >' 189 225 264 285 287 291 302 301 308
27 int_nosucc_lookup 'std::unordered_map<std::__cxx11::basic_string<char> std::__cxx11::basic_string<char> >' 568 2173 1793 2297 2845 376 3789 388 384
28 int_delete 'std::unordered_map<std::__cxx11::basic_string<char> std::__cxx11::basic_string<char> >' 243 828 342 365 373 375 388 386 394
29 int_insert 'std::unordered_map<std::__cxx11::basic_string<char> std::__cxx11::basic_string<char> >' 350 290 296 501 942 349 340 346 355
30 int_succ_lookup 'std::unordered_map<std::__cxx11::basic_string<char> std::__cxx11::basic_string<char> >' 180 237 249 385 476 289 283 288 291
31 int_nosucc_lookup 'std::unordered_map<std::__cxx11::basic_string<char> std::__cxx11::basic_string<char> >' 665 1202 1745 3419 4709 321 3521 332 350
32 int_delete 'std::unordered_map<std::__cxx11::basic_string<char> std::__cxx11::basic_string<char> >' 246 310 322 457 1076 353 371 373 386
33

View File

@ -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;
}
}

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;
}