[lldb-dev] fate of TimeValue

Pavel Labath via lldb-dev lldb-dev at lists.llvm.org
Thu Oct 6 17:39:31 PDT 2016


Hello all,

in line with the "deinventing the wheel" movement, I'd like to remove the
TimeValue class from LLDB. I've done some research on a flight this week,
and as far as I can tell all functionality can be easily replaced with
appropriate usage of std::chrono::duration and time_point.

The only parts that are missing are the ability to convert to/from legacy C
types (struct timevalue, struct timespec), which can be replaced by utility
functions.

Also, I've found one use case particularly cumbersome to write in the c++
way: writing out a duration as a fractional number of units (e.g.
milliseconds). So, I'd propose adding the following utility function as
well (unless someone knows a cleaner way to write this):

template<typename DurOut, typename DurIn>
double float_duration(DurIn dur) {
  return std::chrono::duration_cast<std::chrono::duration<double,
DurOut::period>>(dur).count();
}

Then, you can write float_duration<milliseconds>(dur) to get the duration
as a fractional number of milliseconds (used in printing time deltas in a
human readable fashion).

Any thoughts or objections?

pl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20161006/79cd247b/attachment.html>


More information about the lldb-dev mailing list