36 lines
1.1 KiB
C++
36 lines
1.1 KiB
C++
#include "bsp_1_e.h"
|
|
#include <iostream>
|
|
#include <chrono>
|
|
// BSP 1_E
|
|
using namespace std;
|
|
|
|
int main()
|
|
{
|
|
int n = 1e4;
|
|
// verwende nicht 1e6 und höher - braucht 100s und aufwärts (Vektor)
|
|
// für 1e5 benötigt die Liste recht lang, einige Minuten
|
|
|
|
// Vektoren
|
|
vector<int> x = gensortvec(n);
|
|
vector<int> y = genrandvec(n);
|
|
|
|
auto time1start = chrono::system_clock::now();
|
|
vector<int> s1 = sortvec(x,y);
|
|
auto time1end = chrono::system_clock::now();
|
|
auto time1 = chrono::duration_cast<chrono::milliseconds>(time1end - time1start);
|
|
cout << "Vektor, n = " << n << endl;
|
|
cout << "time needed: " << time1.count() << " ms" << endl << endl;
|
|
|
|
// Listen
|
|
list<int> a = gensortlist(n);
|
|
list<int> b = genlistfromvec(y);
|
|
|
|
auto time2start = chrono::system_clock::now();
|
|
list<int> s2 = sortlist(a,b);
|
|
auto time2end = chrono::system_clock::now();
|
|
auto time2 = chrono::duration_cast<chrono::milliseconds>(time2end - time2start);
|
|
cout << "Liste, n = " << n << endl;
|
|
cout << "time needed: " << time2.count() << " ms" << endl << endl;
|
|
|
|
return 0;
|
|
}
|