Jump to page: 1 2 3
Thread overview
[phobos] Proposal of StopWatch module
Aug 17, 2010
SHOO
Aug 17, 2010
SHOO
Aug 17, 2010
Jonathan M Davis
Aug 17, 2010
SHOO
Aug 17, 2010
SHOO
Aug 17, 2010
Michael Parker
Aug 18, 2010
SHOO
Aug 18, 2010
Michael Parker
Aug 17, 2010
David Simcha
Aug 17, 2010
SHOO
Aug 17, 2010
David Simcha
Aug 18, 2010
SHOO
Aug 18, 2010
Jonathan M Davis
Aug 18, 2010
SHOO
August 17, 2010
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.
August 17, 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


August 17, 2010
in anticipation of what might happen...

Tango does have a StopWatch object, it looks like this (API only):

void start()
Start the timer
double stop()
Stop the timer and return elapsed duration since start()
ulong microsec()
Return elapsed time since the last start() as microseconds
static this()
Setup timing information for later use
ulong timer() [private, static]
Return the current time as an IntervalI hate to do this, but I don't want to
incur any more issues from the Tango team.  Have you looked at this tango module
before writing your StopWatch object (note the StopWatch module is separate from
the other tango modules)?

-Steve



----- Original Message ----
> From: SHOO <zan77137 at nifty.com>
> To: phobos at puremagic.com
> Sent: Tue, August 17, 2010 6:43:41 AM
> Subject: [phobos] Proposal of StopWatch module
> 
> 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
> 



August 17, 2010
Near the bottom of SHOOs e-mail, he does explicitly say he didn't look at Tango.

I see no reason not to trust that, similar APIs notwithstanding.  There really aren't that many ways to make a sensible stopwatch API -- you need a start(), a stop(), and some way to extract the time inbetween in various units.  std.perf.PerformanceCounter looks like that too.

-Lars



On Tue, 2010-08-17 at 05:05 -0700, Steve Schveighoffer wrote:
> in anticipation of what might happen...
> 
> Tango does have a StopWatch object, it looks like this (API only):
> 
> void start()
> Start the timer
> double stop()
> Stop the timer and return elapsed duration since start()
> ulong microsec()
> Return elapsed time since the last start() as microseconds
> static this()
> Setup timing information for later use
> ulong timer() [private, static]
> Return the current time as an IntervalI hate to do this, but I don't want to
> incur any more issues from the Tango team.  Have you looked at this tango module
> before writing your StopWatch object (note the StopWatch module is separate from
> the other tango modules)?
> 
> -Steve
> 
> 
> 
> ----- Original Message ----
> > From: SHOO <zan77137 at nifty.com>
> > To: phobos at puremagic.com
> > Sent: Tue, August 17, 2010 6:43:41 AM
> > Subject: [phobos] Proposal of StopWatch module
> > 
> > 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
> > 
> 
> 
> 
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos


August 17, 2010
thanks, I missed that.

Sorry for the noise, SHOO.

-Steve



----- Original Message ----
> From: Lars Tandle Kyllingstad <lars at kyllingen.net>
> To: Discuss the phobos library for D <phobos at puremagic.com>
> Sent: Tue, August 17, 2010 8:17:04 AM
> Subject: Re: [phobos] Proposal of StopWatch module
> 
> Near the bottom of SHOOs e-mail, he does explicitly say he didn't look at  Tango.
> 
> I see no reason not to trust that, similar APIs  notwithstanding.  There really aren't that many ways to make a sensible  stopwatch API -- you need a start(), a stop(), and some way to extract the  time inbetween in various units.  std.perf.PerformanceCounter looks like  that too.
> 
> -Lars
> 
> 
> 
> On Tue, 2010-08-17 at 05:05 -0700, Steve  Schveighoffer wrote:
> > in anticipation of what might happen...
> > 
> > Tango does have a StopWatch object, it looks like this (API  only):
> > 
> > void start()
> > Start the timer
> > double  stop()
> > Stop the timer and return elapsed duration since start()
> >  ulong microsec()
> > Return elapsed time since the last start() as  microseconds
> > static this()
> > Setup timing information for later  use
> > ulong timer() [private, static]
> > Return the current time as  an IntervalI hate to do this, but I don't want to
>
> > incur any more issues  from the Tango team.  Have you looked at this tango
>module
>
> > before  writing your StopWatch object (note the StopWatch module is separate
>from
>
> > the other tango modules)?
> > 
> > -Steve
> > 
> > 
> > 
> > ----- Original Message ----
> > > From: SHOO <zan77137 at nifty.com>
> > > To: phobos at puremagic.com
> > > Sent:  Tue, August 17, 2010 6:43:41 AM
> > > Subject: [phobos] Proposal of  StopWatch module
> > > 
> > > 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
> > > 
> > 
> > 
> > 
> >  _______________________________________________
> > phobos mailing  list
> > phobos at puremagic.com
> > http://lists.puremagic.com/mailman/listinfo/phobos
> 
> 
> _______________________________________________
> phobos  mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
> 



August 17, 2010
(2010/08/17 21:05), Steve Schveighoffer wrote:
> in anticipation of what might happen...
>
> Tango does have a StopWatch object, it looks like this (API only):
>
> void start()
> Start the timer
> double stop()
> Stop the timer and return elapsed duration since start()
> ulong microsec()
> Return elapsed time since the last start() as microseconds
> static this()
> Setup timing information for later use
> ulong timer() [private, static]
> Return the current time as an IntervalI hate to do this, but I don't want to
> incur any more issues from the Tango team.  Have you looked at this tango module
> before writing your StopWatch object (note the StopWatch module is separate from
> the other tango modules)?

No, I haven't.

This module originates codes that I made when I used C++ (more than 5
years ago).
I know that Tango is having similar class. But I have never, not once,
used Tango's StopWatch.
It of Tango loses accuracy clearly as far as I look API. It of Tango
seems to lose accuracy as far as I look APIs.


FYI, I named this class Timer at first.
But "timer" is strong in an impression called a tool generating a
specific event after a certain period of time for me. It resembles the
function that an alarm clock sounds alarm.
Additionally, my StopWatch imitates real stopwatch.
e.g.)
Constructor/reset() = Push initialize button
start() = Push start button
stop() = Push pause button(toggle)
peek() = Watch the display and read numbers
start() = Push pause button(toggle)
peek() = Peek the display in real time
August 17, 2010
Yes, Lars pointed out to me that you had already stated it wasn't based on Tango.

Sorry for the question, I hate to ask those kinds of questions.  I should have read your post more thoroughly.

-Steve



----- Original Message ----
> From: SHOO <zan77137 at nifty.com>
> To: phobos at puremagic.com
> Sent: Tue, August 17, 2010 9:22:54 AM
> Subject: Re: [phobos] Proposal of StopWatch module
> 
> (2010/08/17 21:05), Steve Schveighoffer wrote:
> > in anticipation of what  might happen...
> > 
> > Tango does have a StopWatch object, it looks  like this (API only):
> > 
> > void start()
> > Start the  timer
> > double stop()
> > Stop the timer and return elapsed duration  since start()
> > ulong microsec()
> > Return elapsed time since the  last start() as microseconds
> > static this()
> > Setup timing  information for later use
> > ulong timer() [private, static]
> > Return  the current time as an IntervalI hate to do this, but I don't want
to
> >  incur any more issues from the Tango team.  Have you looked at this tango
>module
> > before writing your StopWatch object (note the StopWatch module  is separate
>from
> > the other tango modules)?
> 
> No, I  haven't.
> 
> This module originates codes that I made when I used C++ (more  than 5 years
>ago).
> I know that Tango is having similar class. But I have  never, not once, used
>Tango's StopWatch.
> It of Tango loses accuracy clearly  as far as I look API. It of Tango seems to
>lose accuracy as far as I look  APIs.
> 
> 
> FYI, I named this class Timer at first.
> But "timer" is  strong in an impression called a tool generating a specific
>event after a  certain period of time for me. It resembles the function that an alarm clock  sounds alarm.
> Additionally, my StopWatch imitates real  stopwatch.
> e.g.)
> Constructor/reset() = Push initialize button
> start() =  Push start button
> stop() = Push pause button(toggle)
> peek() = Watch the  display and read numbers
> start() = Push pause button(toggle)
> peek() = Peek  the display in real  time
> _______________________________________________
> phobos mailing  list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
> 



August 17, 2010
(2010/08/17 20:33), Lars Tandle Kyllingstad wrote:
> 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.
>

Are not you worried about a function name getting longer?
(I completely agree that Mseconds looks like megaseconds. :) )
Hmm, maybe I'll try to add this rather:
alias seconds sec;
alias milliseconds msec;
alias microseconds usec;

>
> 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.
>

I cannot apply all.
As for it, a dimension occasionally changes.
[s] + [s] == [s]
[s] - [s] == [s]
but
[s] / [s] == [%]
[s] * [s] == [s^2]

In addition, the calculation between the values that dimensions are different needs attention.

[s] + [no dimension] -> x
[s] - [no dimension] -> x
[s] * [no dimension] -> [s]
[s] / [no dimension] -> [s]

I think that avoidance of coexisting is better when I consider a document.

Bug 2460 is troublesome.
It can become hotbeds of the bug if return rvalue...

I make an effort to comply with your advice as possible as.


>
> 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
>
>
>

It's interesting.
I think I want compiler to generate it automatically.
August 17, 2010
This is great, but there are issues with QueryPerformanceCounter that I
think ought to be pointed out if you aren't already aware of them. QPC is
horribly unreliable
on some chipsets and, on some systems, when running on multiple cores. Both
issues are decribed in the MS Knowledge Base,
with the chipset problem at [1] and the multicore problem at [2]. In the
latter, pay particular attention to point #4 in the Recommendations
section.

Starting with Vista, QPC will use the newer High Precision Event Timer [3],
if available (which it should be for most systems running Vista or 7),
so this becomes less of an issue. But for XP, which is still going to be
relevant for a few more years at least, this is a big headache. You can
read more about timing issues in the PDF at [4].

If I were going to use this class in a game, I would expect it to take the recommended precautions on XP. Otherwise, I'd just roll my own using timeGetTime.

[1] http://support.microsoft.com/kb/274323
[2] http://msdn.microsoft.com/en-us/library/ee417693.aspx
[3] http://en.wikipedia.org/wiki/High_Precision_Event_Timer
[4] (direct PDF link)
http://algo2.iti.kit.edu/wassenberg/timing/timing_pitfalls.pdf

On Tue, Aug 17, 2010 at 7:43 PM, SHOO <zan77137 at nifty.com> 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
>



-- 
Mike Parker
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20100817/2df5bf7b/attachment.html>
August 17, 2010
(2010/08/17 22:28), Steve Schveighoffer wrote:
> Yes, Lars pointed out to me that you had already stated it wasn't based on Tango.
>
> Sorry for the question, I hate to ask those kinds of questions.  I should have read your post more thoroughly.
>
> -Steve

Please don't mind it. We should be sensitive about the license.
In particular, I got this problem before. Thank you for minding it.
« First   ‹ Prev
1 2 3