> On Sept. 23, 2013, 11:04 p.m., Ben Mahler wrote:
> > 3rdparty/libprocess/3rdparty/stout/include/stout/duration.hpp, lines 286-287
> > <https://reviews.apache.org/r/11331/diff/4/?file=356211#file356211line286>
> >
> > What about making this class a friend of Duration (to gain access to
> > the constants) and then instead of using casting with doubles you can use
> > just use mod operations on integers:
> >
> > int64_t nanoseconds = duration.ns();
> >
> > ...
> >
> > if (nanoseconds % MILLISECONDS != 0 && nanoseconds % MICROSECONDS
> > == 0) {
> > stream << duration.us() << "us";
> > } else {
> > stream << duration.ms() << "ms";
> > }
> >
> > Would be nice to get rid of the double casting, thoughts?
OK it does look a bit better. If we trust compiler optimization and use
qualified names:
if (duration.ns() % Duration::MILLISECONDS != 0 &&
duration.ns() % Duration::MICROSECONDS == 0) {
stream << duration.us() << "us";
} else {
stream << duration.ms() << "ms";
}
Looks OK?
- Jiang Yan
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/11331/#review26328
-----------------------------------------------------------
On Sept. 23, 2013, 9:28 p.m., Jiang Yan Xu wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/11331/
> -----------------------------------------------------------
>
> (Updated Sept. 23, 2013, 9:28 p.m.)
>
>
> Review request for mesos, Benjamin Hindman, Ben Mahler, Ian Downes, Jie Yu,
> and Vinod Kone.
>
>
> Bugs: MESOS-477
> https://issues.apache.org/jira/browse/MESOS-477
>
>
> Repository: mesos
>
>
> Description
> -------
>
> - Currently when the result isn't a whole number, we go one-level down in
> terms of the unit of time and see if we can get a whole number there. If so,
> use the lower unit; if not, use the higher unit.
>
>
> Diffs
> -----
>
> 3rdparty/libprocess/3rdparty/stout/include/stout/duration.hpp
> 47e85ff8bbb310475dea382bfca9389c4295cf77
> 3rdparty/libprocess/3rdparty/stout/tests/duration_tests.cpp
> e0910d4c82c2289f8d08deadbf4a8ef0448d0f76
>
> Diff: https://reviews.apache.org/r/11331/diff/
>
>
> Testing
> -------
>
> make check
>
>
> Thanks,
>
> Jiang Yan Xu
>
>