Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
758f606d
Commit
758f606d
authored
Oct 14, 2015
by
Davis King
Browse files
Added the option to always print status when using the
console_progress_indicator.
parent
f72c78eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
10 deletions
+15
-10
dlib/console_progress_indicator.h
dlib/console_progress_indicator.h
+15
-10
No files found.
dlib/console_progress_indicator.h
View file @
758f606d
...
@@ -65,7 +65,8 @@ namespace dlib
...
@@ -65,7 +65,8 @@ namespace dlib
!*/
!*/
inline
bool
print_status
(
inline
bool
print_status
(
double
cur
double
cur
,
bool
always_print
=
false
);
);
/*!
/*!
ensures
ensures
...
@@ -74,10 +75,13 @@ namespace dlib
...
@@ -74,10 +75,13 @@ namespace dlib
remaining until cur becomes equal to target().
remaining until cur becomes equal to target().
- prints a status message to the screen which indicates how much
- prints a status message to the screen which indicates how much
more time is left until cur is equal to target()
more time is left until cur is equal to target()
- This function throttles the printing so that at most 1 message is printed
- if (always_print) then
each second. Note that it won't print anything to the screen until about
- This function prints to the screen each time it is called.
one second has elapsed. This means that the first call to print_status()
- else
never prints to the screen.
- This function throttles the printing so that at most 1 message is
printed each second. Note that it won't print anything to the screen
until about one second has elapsed. This means that the first call
to print_status() never prints to the screen.
- This function returns true if it prints to the screen and false
- This function returns true if it prints to the screen and false
otherwise.
otherwise.
!*/
!*/
...
@@ -115,7 +119,8 @@ namespace dlib
...
@@ -115,7 +119,8 @@ namespace dlib
bool
console_progress_indicator
::
bool
console_progress_indicator
::
print_status
(
print_status
(
double
cur
double
cur
,
bool
always_print
)
)
{
{
const
time_t
cur_time
=
std
::
time
(
0
);
const
time_t
cur_time
=
std
::
time
(
0
);
...
@@ -132,7 +137,7 @@ namespace dlib
...
@@ -132,7 +137,7 @@ namespace dlib
return
false
;
return
false
;
}
}
if
(
cur_time
!=
last_time
)
if
(
cur_time
!=
last_time
||
always_print
)
{
{
last_time
=
cur_time
;
last_time
=
cur_time
;
double
delta_t
=
static_cast
<
double
>
(
cur_time
-
start_time
);
double
delta_t
=
static_cast
<
double
>
(
cur_time
-
start_time
);
...
@@ -152,17 +157,17 @@ namespace dlib
...
@@ -152,17 +157,17 @@ namespace dlib
if
(
seconds
<
60
)
if
(
seconds
<
60
)
{
{
ss
=
std
::
cout
.
precision
(
0
);
ss
=
std
::
cout
.
precision
(
0
);
std
::
cout
<<
"Time remaining: "
<<
seconds
<<
" seconds.
\r
"
<<
std
::
flush
;
std
::
cout
<<
"Time remaining: "
<<
seconds
<<
" seconds.
\r
"
<<
std
::
flush
;
}
}
else
if
(
seconds
<
60
*
60
)
else
if
(
seconds
<
60
*
60
)
{
{
ss
=
std
::
cout
.
precision
(
2
);
ss
=
std
::
cout
.
precision
(
2
);
std
::
cout
<<
"Time remaining: "
<<
seconds
/
60
<<
" minutes.
\r
"
<<
std
::
flush
;
std
::
cout
<<
"Time remaining: "
<<
seconds
/
60
<<
" minutes.
\r
"
<<
std
::
flush
;
}
}
else
else
{
{
ss
=
std
::
cout
.
precision
(
2
);
ss
=
std
::
cout
.
precision
(
2
);
std
::
cout
<<
"Time remaining: "
<<
seconds
/
60
/
60
<<
" hours.
\r
"
<<
std
::
flush
;
std
::
cout
<<
"Time remaining: "
<<
seconds
/
60
/
60
<<
" hours.
\r
"
<<
std
::
flush
;
}
}
// restore previous output flags and precision settings
// restore previous output flags and precision settings
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment