How do people run simple timing tests in Ciao? In SWI-Prolog I can do the following:
benchmark1 :- flag(benchmark,_,0), repeat, zebra1(Houses, WaterDrinker, ZebraOwner), flag(benchmark,N,N+1), N = 1000, !. benchmark :- time(benchmark1).
What is the equivalent in Ciao?
Thanks! David
Hi David, I wrote a small module to help benchmark time in library(profiler(profiler_extra)), just see the following example that measure the reverse/2 predicate:
:- module(_, _, []).
:- use_module(library(profiler(profiler_extra))). :- use_module(library(lists)).
mytest(Time) :- length(List, 1000), measure(reverse(List, _Rev), Time).
By default the time is given in the maximum resolution unit available in the system. In Intel, for example, it is given in cpu cycles. For milliseconds, you can use measure(Goal, walltime, Time). Just see the ciao/contrib/profiler/profiler_extra.pl file, I guess it is not too difficult to follow. Best Regards,
Edison.
2012/5/13 David Nolen <dnolen.lists(a)gmail.com>
How do people run simple timing tests in Ciao? In SWI-Prolog I can do the following:
benchmark1 :- flag(benchmark,_,0), repeat, zebra1(Houses, WaterDrinker, ZebraOwner), flag(benchmark,N,N+1), N = 1000, !. benchmark :- time(benchmark1).
What is the equivalent in Ciao?
Thanks! David
Ciao-users mailing list Ciao-users(a)clip.dia.fi.upm.es http://clip.dia.fi.upm.es/cgi-bin/mailman/listinfo/ciao-users
On Mon, May 14, 2012 at 11:33 AM, Edison Mera <efmera(a)gmail.com> wrote:
Hi David, I wrote a small module to help benchmark time in library(profiler(profiler_extra)), just see the following example that [...]
Just a minor note: like most libraries under contrib/, we do not ensure that they will be API-stable. If you need portability, statistics/2 is recommended.
To make it clear, we considered at some point extending LPdoc with annotations to document stability of module interfaces and portability. Any suggestion in this respect is welcome and really appreciated.
Cheers,
On Sun, May 13, 2012 at 9:20 PM, David Nolen <dnolen.lists(a)gmail.com> wrote:
How do people run simple timing tests in Ciao? In SWI-Prolog I can do the following:
benchmark1 :- flag(benchmark,_,0), repeat, zebra1(Houses, WaterDrinker, ZebraOwner), flag(benchmark,N,N+1), N = 1000, !. benchmark :- time(benchmark1).
What is the equivalent in Ciao?
Dear David,
there is no equivalent in Ciao for SWI time/1, but you can program it, e.g.:
:- meta_predicate time(goal). time(G) :- statistics(runtime, [T0|_]), G, statistics(runtime, [T1|_]), T is T1 - T0, write('time: '), write(T), nl.
The main reason why Ciao lacks this predicate is that, when doing extensive benchmarking, you need something more sophisticated than time/1. We could add it if there is enough interest. However, I think that something similar to 'benchmark.js' (used in jsperf.com) would be nicer.
Cheers