Stopwatch in Logtalk

Help requests on developing Logtalk applications

Moderator: Paulo Moura

Post Reply
ecols
Posts: 2
Joined: Tue Jan 27, 2009 11:26 am

Stopwatch in Logtalk

Post by ecols » Wed Feb 11, 2009 5:58 pm

Hi there!

I am using Logtalk to simply store Data in a StateMachine, without letting the number of States explode ;) Everything works totally well and I'm really amazed what You can do with Logtalk. I will certainly go into it some more!

Now I wanted to have a global stopwatch to trigger benchmarks. I thought I had seen something like that recently but just can't find it anymore! It kind of catched messages, started the watch and stopped as soon as the reply was sent. I think that's a very handy tool! Has anyone got an idea where I could find that snippet of code? I'm pretty sure it's open source.

Anyways: Is there a reliable possibility to measure time in Logtalk? I could even go with something like:

stopwatch::start,
[code ....]

stopwatch::stop.

But the built in Prolog System Time function behaves weirdly.. It prints out VERY different times for the same operations (factor 3).

greets

ecols

Paulo Moura
Logtalk developer
Posts: 474
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: Stopwatch in Logtalk

Post by Paulo Moura » Wed Feb 11, 2009 7:20 pm

ecols wrote: I am using Logtalk to simply store Data in a StateMachine, without letting the number of States explode ;) Everything works totally well and I'm really amazed what You can do with Logtalk. I will certainly go into it some more!
:-)
Now I wanted to have a global stopwatch to trigger benchmarks. I thought I had seen something like that recently but just can't find it anymore! It kind of catched messages, started the watch and stopped as soon as the reply was sent. I think that's a very handy tool! Has anyone got an idea where I could find that snippet of code? I'm pretty sure it's open source.
Are you talking about the Logtalk "profiling" example?
Anyways: Is there a reliable possibility to measure time in Logtalk? I could even go with something like:

stopwatch::start,
[code ....]

stopwatch::stop.

But the built in Prolog System Time function behaves weirdly.. It prints out VERY different times for the same operations (factor 3).
Which back-end Prolog compiler are you using with Logtalk? You could try to use the Logtalk library object "time" but for reliable results you will probably need a to repeat your benchmarks a sufficient number of times. See also the "benchmarks" example.
Paulo Moura
Logtalk developer

Parker
Posts: 33
Joined: Wed Feb 27, 2008 2:51 pm

Re: Stopwatch in Logtalk

Post by Parker » Wed Feb 11, 2009 7:23 pm

Hi,

Have you looked at the logtalk/examples/profiling examples yet? There is a stopwatch object that does what you seem to be asking.

As for variability, if the execution time is very short the variance will be high, but as the runtime increases the variance decreases and results should be more stable (at least until garbage collection starts).

Hope that helps.
Parker

ecols
Posts: 2
Joined: Tue Jan 27, 2009 11:26 am

Re: Stopwatch in Logtalk

Post by ecols » Wed Feb 11, 2009 7:40 pm

Hi there!

Thanks a lot for Your replies! Profiling was exactly what I was looking for. In the meantime I implemented a tiny stopwatch myself, using SWIs "get_time" command. This works surprisingly well. The old code I got used "statistics(runtime, [Time|_])".
Now I can go measuring..

greets

ecols

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest