Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
bb5d72a4
Commit
bb5d72a4
authored
Sep 23, 2020
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove dependency on boost::timer
parent
85d68b93
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
12 deletions
+50
-12
src/CifUtils.cpp
+50
-12
No files found.
src/CifUtils.cpp
View file @
bb5d72a4
...
...
@@ -35,6 +35,8 @@
#include <thread>
#include <filesystem>
#include <fstream>
#include <map>
#include <chrono>
#if defined(_MSC_VER)
#define TERM_WIDTH 80
...
...
@@ -44,8 +46,6 @@
#endif
#include <boost/algorithm/string.hpp>
#include <boost/timer/timer.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include "cif++/CifUtils.hpp"
...
...
@@ -467,8 +467,7 @@ struct ProgressImpl
{
ProgressImpl
(
int64_t
inMax
,
const
std
::
string
&
inAction
)
:
mMax
(
inMax
),
mConsumed
(
0
),
mAction
(
inAction
),
mMessage
(
inAction
)
,
mThread
(
std
::
bind
(
&
ProgressImpl
::
Run
,
this
))
,
mStart
(
boost
::
posix_time
::
second_clock
::
local_time
())
{}
,
mThread
(
std
::
bind
(
&
ProgressImpl
::
Run
,
this
))
{}
void
Run
();
void
Stop
()
...
...
@@ -482,22 +481,19 @@ struct ProgressImpl
void
PrintDone
();
int64_t
mMax
;
std
::
atomic
<
int64_t
>
mConsumed
;
std
::
atomic
<
int64_t
>
mConsumed
;
int64_t
mLastConsumed
=
0
;
int
mSpinnerIndex
=
0
;
std
::
string
mAction
,
mMessage
;
std
::
mutex
mMutex
;
std
::
thread
mThread
;
boost
::
timer
::
cpu_timer
mTimer
;
boost
::
posix_time
::
ptime
mStart
;
std
::
chrono
::
time_point
<
std
::
chrono
::
system_clock
>
mStart
=
std
::
chrono
::
system_clock
::
now
()
;
bool
mStop
=
false
;
};
void
ProgressImpl
::
Run
()
{
using
namespace
boost
::
posix_time
;
// using namespace boost::local_time;
bool
printedAny
=
false
;
try
...
...
@@ -511,7 +507,9 @@ void ProgressImpl::Run()
if
(
mStop
or
mConsumed
==
mMax
)
break
;
if
(
second_clock
::
local_time
()
-
mStart
<
seconds
(
5
))
auto
elapsed
=
std
::
chrono
::
system_clock
::
now
()
-
mStart
;
if
(
elapsed
<
std
::
chrono
::
seconds
(
5
))
continue
;
PrintProgress
();
...
...
@@ -612,9 +610,49 @@ void ProgressImpl::PrintProgress()
std
::
cout
.
flush
();
}
namespace
{
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
std
::
chrono
::
duration
<
double
>&
t
)
{
uint64_t
s
=
static_cast
<
uint64_t
>
(
std
::
trunc
(
t
.
count
()));
if
(
s
>
24
*
60
*
60
)
{
uint32_t
days
=
s
/
(
24
*
60
*
60
);
os
<<
days
<<
"d "
;
s
%=
24
*
60
*
60
;
}
if
(
s
>
60
*
60
)
{
uint32_t
hours
=
s
/
(
60
*
60
);
os
<<
hours
<<
"h "
;
s
%=
60
*
60
;
}
if
(
s
>
60
)
{
uint32_t
minutes
=
s
/
60
;
os
<<
minutes
<<
"m "
;
s
%=
60
;
}
double
ss
=
s
+
1e-6
*
(
t
.
count
()
-
s
);
os
<<
std
::
fixed
<<
std
::
setprecision
(
1
)
<<
ss
<<
's'
;
return
os
;
}
}
void
ProgressImpl
::
PrintDone
()
{
std
::
string
msg
=
mAction
+
" done in "
+
mTimer
.
format
(
0
,
"%ts cpu / %ws wall"
);
std
::
chrono
::
duration
<
double
>
elapsed
=
std
::
chrono
::
system_clock
::
now
()
-
mStart
;
std
::
ostringstream
msgstr
;
msgstr
<<
mAction
<<
" done in "
<<
elapsed
<<
" cpu / %ws wall"
;
auto
msg
=
msgstr
.
str
();
uint32_t
width
=
get_terminal_width
();
...
...
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