TickDuration deprecation

Jon Degenhardt jond at noreply.com
Sat Nov 18 22:46:20 UTC 2017


On Saturday, 18 November 2017 at 16:17:00 UTC, Jonathan M Davis 
wrote:
> On Saturday, November 18, 2017 15:03:05 Timon Gehr via 
> Digitalmars-d wrote:
>
> [snip]
>
> Printing out a floating point value for something like the 
> number of seconds can make sense, but using floating point to 
> do math with time really doesn't. And it's trivial enough to do 
> the math yourself to get the number of seconds (or milliseconds 
> or minutes or whatever) as a floating point value if you really 
> want that that I'd much rather not add it to core.time, because 
> that would just be encouraging folks to start using floating 
> point values for something other than simply printing out the 
> value, which will lead to buggy code which could have easily 
> been avoided just by sticking to integral math.
>
When I use timers to measure time durations, whether for program 
performance or something else, at the end I usually want to 
convert to units of time appropriate for what is being measured 
and print it in a format easily consumable by human readers. That 
typically means some fixed precision floating point format.

I admittedly don't understand the argument that it should be hard 
to user programs to convert time durations to alternate standard 
units of measure. But even so, it would seem to make sense for 
the documentation of std.datetime.stopwatch to provide clear 
examples of printing a duration in different standard time units. 
In documentation's current form, it takes quite a bit of digging 
to figure out how to do this. I'd recommend at least making it 
clear in the documentation how to do this. Yes, this would also 
make it easier for users to convert to float, but printing in 
standard units of measure is a rather basic operation.


More information about the Digitalmars-d mailing list