Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
758f606d
Commit
758f606d
authored
Oct 14, 2015
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the option to always print status when using the
console_progress_indicator.
parent
f72c78eb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
10 deletions
+15
-10
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
!*/
inline
bool
print_status
(
double
cur
double
cur
,
bool
always_print
=
false
);
/*!
ensures
...
...
@@ -74,10 +75,13 @@ namespace dlib
remaining until cur becomes equal to target().
- prints a status message to the screen which indicates how much
more time is left until cur is equal to target()
- 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.
- if (always_print) then
- This function prints to the screen each time it is called.
- else
- 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
otherwise.
!*/
...
...
@@ -115,7 +119,8 @@ namespace dlib
bool
console_progress_indicator
::
print_status
(
double
cur
double
cur
,
bool
always_print
)
{
const
time_t
cur_time
=
std
::
time
(
0
);
...
...
@@ -132,7 +137,7 @@ namespace dlib
return
false
;
}
if
(
cur_time
!=
last_time
)
if
(
cur_time
!=
last_time
||
always_print
)
{
last_time
=
cur_time
;
double
delta_t
=
static_cast
<
double
>
(
cur_time
-
start_time
);
...
...
@@ -152,17 +157,17 @@ namespace dlib
if
(
seconds
<
60
)
{
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
)
{
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
{
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
...
...
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