-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathczas.cpp
45 lines (36 loc) · 1.35 KB
/
czas.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// czas.cpp
// 1-programowanie-strukturalne\1-4-dodatkowe\1-4-2-czas
//
// Created by Jakub Piskorowski on 30/03/2022 wersja: 1.0
// Copyright © 2022 Jakub Piskorowski. All rights reserved.
// GitHub: https://github.com/PiskorowskiJakub/programming-course-cpp
//
// Przedstawienie dzialania funkcji losujacej
//
#include <iostream>
#include <chrono>
using namespace std;
chrono::duration<double> elapsed_seconds;
int main() {
chrono::system_clock::time_point start = chrono::system_clock::now(); // czas start
int sum=0; int add = 1;
int iterations = 1000*100*50;
float wynik;
cout << "iteration: " << iterations << endl;
for (int i=0; i<=iterations; i++) {
if(i % 1000 == 0){
wynik =(i*100)/iterations;
system("cls");
cout<< "Progres: "<< wynik<< " % ";
}
}
chrono::system_clock::time_point end = chrono::system_clock::now(); // czas stop
elapsed_seconds += end - start; // obliczenie czasu
cout << "\nCzas: " << endl;
// wyswietlenie czasu w roznych jednostkach
cout << std::chrono::duration_cast<std::chrono::milliseconds>(elapsed_seconds).count()<< "\t milliseconds\n";
cout << std::chrono::duration_cast<std::chrono::seconds>(elapsed_seconds).count()<< "\t seconds\n";
//cout << elapsed_seconds.count() << " second" << endl;
cout << std::chrono::duration_cast<std::chrono::minutes>(elapsed_seconds).count()<< "\t minutes\n";
}