[phobos] Proposal of StopWatch module

Lars Tandle Kyllingstad lars at kyllingen.net
Tue Aug 17 04:33:25 PDT 2010


Looks good!

I just have a few small suggestions:


1. I'd replace fromMseconds and fromUseconds with fromMilliseconds and
fromMicroseconds.  (Mseconds is, strictly speaking, megaseconds...)  And
mseconds->milliseconds, useconds->microseconds, etc.


2. The opOpAssign() functions should return 'this'.  Also, you can
combine them into one:

        Ticks opOpAssign(string op)(Ticks t)
                if (op == "+" || op == "-" || op == "*" || op == "/")
        {
                mixin("value "~op~"= t.value;");
                return this;
        }
        
They should probably return by ref as well, but bug 2460 prevents that.


3. The opBinary() functions can also be combined like that, or you can
even do:

        Ticks opBinary(string op)(Ticks t)
        {
                auto lhs = this;
                return lhs.opOpAssign!op(t);
        }

I think that's a pretty nice idiom.

-Lars



On Tue, 2010-08-17 at 19:43 +0900, SHOO wrote:
> I made the module of the stopwatch, so I suggest it again here.
> 
> I suggested a time handling module that I called std.time before.
> Unfortunately itself was not able to contribute to Phobos for the issue
> of license. But, an important function was included in it. It is what is
> the StopWatch suggested this time.
> 
> I have some knowledge about machine control engineering. In the field of
> the machine control engineering, the high accuracy time measurement
> often plays an important role.
> For example, the case wants to perform the measurement of the voltage
> with time by millisecond order for feedback control. When it looks like
> it, resolution power is not enough by time acquisition such as C's time
> function in many cases.
> 
> Or the high accuracy time measurement is important in the game
> programming, too. Or in benchmark testing, too.
> 
> There is std.perf in Phobos as a module with this role now.
> However, the module is unlisted, and a license doesn't seem to be a
> Boost license, too.
> I did not refer Tango at all about this class and examined and made it
> in my own hand completely.
> 
> Here is the module to suggest this time:
>     http://ideone.com/TVw1P
> 
> # This module is tested by Windows (real) and Ubuntu (virtual PC).
> 
> Please look at it once by all means, and review it.
> I think that I will commit it at 2010-08-22T15:00Z as far as there is
> not serious dissenting opinion.
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos




More information about the phobos mailing list