-
Notifications
You must be signed in to change notification settings - Fork 0
/
Console_print.cpp
executable file
·112 lines (95 loc) · 3.01 KB
/
Console_print.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/* CREDITS
* Author : Martin Garaj <garaj.martin@gmail.com>
* Date : 12/2017
* Project : HPC MPI Testing application
*
* REDISTRIBUTION
* The software is meant for internal use at City University of Hong Kong only.
* Further redistribution/sharing of the software or any parts of the source code without author's permission is disapproved.
*
* DISCLAIMER
* This software comes as is, without any warranty. Use on your own risk.
*
* CHANGE LOG
* Please log any changes below, log the Author, Date and Change done.
* Author | Date | Change
* | YYYY/MM/DD |
*/
// header
#include "Console_print.hpp"
int Console_print::limit_time(unsigned long long time_raw, unsigned int limit, float &time_limited, std::string &unit){
if ( ( (time_raw/_D_) ) > limit){
unit = "Day";
time_limited = ((float)time_raw / _D_);
}else if ( ( (time_raw/_h_) ) > limit){
unit = "h";
time_limited = ((float)time_raw / _h_);
}else if ( ( (time_raw/_m_) ) > limit){
unit = "m";
time_limited = ((float)time_raw / _m_);
}else if ( ( (time_raw/_s_) ) > limit){
unit = "s";
time_limited = ((float)time_raw / _s_);
}else{
unit = "ms";
time_limited = ((float)time_raw);
}
return _SUCCESS_;
}
int Console_print::limit_time(float time_raw, unsigned int limit, float &time_limited, std::string &unit){
if ( ( (time_raw/(float)_D_) ) > limit){
unit = "Day";
time_limited = (time_raw / (float)_D_);
}else if ( ( (time_raw/(float)_h_) ) > limit){
unit = "h";
time_limited = (time_raw / (float)_h_);
}else if ( ( (time_raw/(float)_m_) ) > limit){
unit = "m";
time_limited = (time_raw / (float)_m_);
}else if ( ( (time_raw/(float)_s_) ) > limit){
unit = "s";
time_limited = (time_raw / (float)_s_);
}else{
unit = "ms";
time_limited = (time_raw);
}
return _SUCCESS_;
}
int Console_print::limit_data(unsigned long long data_raw, unsigned int limit, float &date_limited, std::string &unit){
if ( ( (data_raw/_TB_) ) > limit){
unit = "TB";
date_limited = ((float)data_raw / _TB_);
}else if ( ( (data_raw/_GB_) ) > limit){
unit = "GB";
date_limited = ((float)data_raw / _GB_);
}else if ( ( (data_raw/_MB_) ) > limit){
unit = "MB";
date_limited = ((float)data_raw / _MB_);
}else if ( ( (data_raw/_KB_) ) > limit){
unit = "KB";
date_limited = ((float)data_raw / _KB_);
}else{
unit = "B";
date_limited = ((float)data_raw);
}
return _SUCCESS_;
}
int Console_print::limit_data(float data_raw, unsigned int limit, float &date_limited, std::string &unit){
if ( ( (data_raw/(float)_TB_) ) > limit){
unit = "TB";
date_limited = (data_raw / (float)_TB_);
}else if ( ( (data_raw/(float)_GB_) ) > limit){
unit = "GB";
date_limited = (data_raw / (float)_GB_);
}else if ( ( (data_raw/(float)_MB_) ) > limit){
unit = "MB";
date_limited = (data_raw / (float)_MB_);
}else if ( ( (data_raw/(float)_KB_) ) > limit){
unit = "KB";
date_limited = (data_raw / (float)_KB_);
}else{
unit = "B";
date_limited = (data_raw);
}
return _SUCCESS_;
}