Dateien nach „BSP_1_C“ hochladen
This commit is contained in:
parent
9800c3596d
commit
4c4507811c
4 changed files with 169 additions and 0 deletions
53
BSP_1_C/main.cpp
Normal file
53
BSP_1_C/main.cpp
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#include "bsp_1_c.h"
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
// BSP 1_C
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
long long int n1 = 15;
|
||||
long long int n2 = 1001;
|
||||
long long int n3 = 1432987;
|
||||
|
||||
cout << "n = " << n1 << endl;
|
||||
cout << "Funktion 1 / loops" << endl;
|
||||
cout << fkt1(n1) << endl;
|
||||
cout << "Funktion 2 / Formel" << endl;
|
||||
cout << fkt2(n1) << endl << endl;
|
||||
|
||||
cout << "n = " << n2 << endl;
|
||||
cout << "Funktion 1 / loops" << endl;
|
||||
cout << fkt1(n2) << endl;
|
||||
cout << "Funktion 2 / Formel" << endl;
|
||||
cout << fkt2(n2) << endl << endl;
|
||||
|
||||
cout << "n = " << n3 << endl;
|
||||
cout << "Funktion 1 / loops" << endl;
|
||||
cout << fkt1(n3) << endl;
|
||||
cout << "Funktion 2 / Formel" << endl;
|
||||
cout << fkt2(n3) << endl << endl;
|
||||
|
||||
|
||||
// ad Zeitmessung beider Funktionen
|
||||
auto time1start = std::chrono::system_clock::now();
|
||||
for (int k = 1; k <= 10000; ++k)
|
||||
{
|
||||
fkt1(n3);
|
||||
}
|
||||
auto time1end = std::chrono::system_clock::now();
|
||||
auto time1 = std::chrono::duration_cast<std::chrono::milliseconds>(time1end - time1start);
|
||||
cout << "benoetigte Zeit fuer Funktion 1 (10000 maliger Aufruf; n=1432987): " << time1.count() << "ms" << endl;
|
||||
|
||||
auto time2start = std::chrono::system_clock::now();
|
||||
for (int k = 1; k <= 10000; ++k)
|
||||
{
|
||||
fkt2(n3);
|
||||
}
|
||||
auto time2end = std::chrono::system_clock::now();
|
||||
auto time2 = std::chrono::duration_cast<std::chrono::milliseconds>(time2end - time2start);
|
||||
cout << "benoetigte Zeit fuer Funktion 2 (10000 maliger Aufruf; n=1432987): " << time2.count() << "ms" << endl;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue