Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
e8ed802d
Commit
e8ed802d
authored
Apr 20, 2015
by
Marcin Siodelski
Browse files
[3804] Fixed broken conversion of duration to text
parent
04b76159
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/util/stopwatch_impl.cc
View file @
e8ed802d
...
...
@@ -13,6 +13,7 @@
// PERFORMANCE OF THIS SOFTWARE.
#include <util/stopwatch_impl.h>
#include <iomanip>
#include <sstream>
namespace
isc
{
...
...
@@ -87,7 +88,8 @@ std::string
StopwatchImpl
::
logFormat
(
const
boost
::
posix_time
::
time_duration
&
duration
)
{
std
::
ostringstream
s
;
s
<<
duration
.
total_milliseconds
()
<<
"."
;
s
<<
(
duration
.
total_microseconds
()
%
1000
)
<<
" ms"
;
s
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
3
)
<<
(
duration
.
total_microseconds
()
%
1000
)
<<
" ms"
;
return
(
s
.
str
());
}
...
...
src/lib/util/tests/stopwatch_unittest.cc
View file @
e8ed802d
...
...
@@ -287,14 +287,14 @@ TEST_F(StopwatchTest, autostart) {
// Make sure that the conversion to the loggable string works as expected.
TEST_F
(
StopwatchTest
,
logFormat
)
{
time_duration
duration
=
microseconds
(
223
5
43
);
EXPECT_EQ
(
"223.
5
43 ms"
,
StopwatchImpl
::
logFormat
(
duration
));
time_duration
duration
=
microseconds
(
223
0
43
);
EXPECT_EQ
(
"223.
0
43 ms"
,
StopwatchImpl
::
logFormat
(
duration
));
duration
=
microseconds
(
1234
);
EXPECT_EQ
(
"1.234 ms"
,
StopwatchImpl
::
logFormat
(
duration
));
duration
=
microseconds
(
2000
);
EXPECT_EQ
(
"2.0 ms"
,
StopwatchImpl
::
logFormat
(
duration
));
EXPECT_EQ
(
"2.0
00
ms"
,
StopwatchImpl
::
logFormat
(
duration
));
}
}
// end of anonymous namespace
Write
Preview
Supports
Markdown
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