-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStage.cpp
63 lines (57 loc) · 1.43 KB
/
Stage.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//CONTROLLARE LETTURA FILE
#include "Stage.hpp"
void Stage::set_dependencies(const std::vector<id_type> v){
dependencies = v;
};
void Stage::set_max (const std::vector<time_instant>& v){
//max execution time in a stage
time_instant temp = 0;
for(auto t : v){
if(t > temp){
temp = t;
}
}
max = temp;
}
void Stage::set_min (const std::vector<time_instant>& v){
//min execution time in a stage
time_instant temp = v[0];
for(auto t : v){
if(t < temp){
temp = t;
}
}
min = temp;
}
void Stage::set_avg (const std::vector<time_instant>& v){
//avg execution time in a stage
time_instant sum = 0;
for(auto t : v){
sum += t;
}
avg = sum/v.size();
}
void Stage::prints() const{
std::cout << '\n';
std::cout << "Id stage: " << id_Stage << '\n' << " avg time: " << this->get_avg() << '\n';
std::cout << "Number of tasks: " << n_tasks << '\n';
// if(dependencies.empty()){
// std::cout << "No dependencies on other stages" << '\n';
// }
// else{
// std::cout << "dependencies on stages: " << '\n';
// for (size_t i = 0; i < dependencies.size(); i++) {
// std::cout << dependencies[i] << " ";
// }
// std::cout << '\n';
// }
}
Stage& Stage::operator=(const Stage& stage){
id_Stage = stage.get_ID();
max = stage.get_max();
min = stage.get_min();
avg = stage.get_avg();
n_tasks = stage.get_n_tasks();
dependencies = stage.get_depend();
return *this;
}