[phobos] std.datetime and tick types

Robert Jacques sandford at jhu.edu
Mon Sep 27 22:08:12 PDT 2010


On Mon, 27 Sep 2010 11:51:00 -0400, Jonathan M Davis <jmdavisProg at gmx.com>  
wrote:

> On Monday 27 September 2010 07:52:48 Robert Jacques wrote:
>> On Mon, 27 Sep 2010 09:52:17 -0400, SHOO <zan77137 at nifty.com> wrote:
>> > (2010/09/27 20:22), Jonathan M Davis wrote:
>> >> /++
>> >>
>> >>      Represents possible units of time.
>> >>
>> >>    +/
>> >>
>> >> enum TUnit { year, month, week, day, hour, minute, second,  
>> millisecond,
>> >> microsecond, stdTick }
>>
>> [snip]
>>
>> >> What I'd really like is to find a better name than tick or std tick  
>> for
>> >> my ticks.
>> >> What would that be anyway? A deci-microsecond? A centa-nanosecond?
>> >> Either name
>> >> would be horrible.
>>
>> A hundred nanoseconds would be a deci-microsecond or a hecto-nanosecond.
>> Both are used, though hectonanosecond seems to be more popular, both
>> generally and with programmers. For example, Apple's Network Time  
>> Protocol
>> codebase uses the unit. I don't find either name horrible and would  
>> prefer
>> an actual unit of time in TUnit as opposed to a made up name which I'd
>> have to remember is actually a hectonanosecond. Perhaps this is my
>> scientific background coming through.
>
> Well, aside from the fact that I think that most people have never heard  
> of a
> hectonanosecond, it's awfully long to type. millisecond and microsecond  
> are bad
> enough. And do you really want to have to use functions like
> totalHectonanoseconds()? Perhaps with a good abbrevation... hnsec? I'll  
> have to
> think about it. As words go, ticks is far more pleasant, but it isn't as
> precise.
>
> - Jonathan M Davis

Well, if you make up a unit, then you can guarantee no one will have heard  
of it before. And really, learning the hecto SI prefix means someone will  
always understand what hectonanosecond means, as opposed to StdTick or  
Duration, etc, which would have a tendency to be quickly forgotten or  
confused with another library type from another language. As for typing, I  
would expect the 100ns unit to be mainly an internal thing. Most of the  
time I deal in microseconds/1000.0 (i.e. floating point milliseconds),  
when dealing with std.perf today.


More information about the phobos mailing list