________________________________________________________________________

This file is part of Logtalk <https://logtalk.org/>  
Copyright 1998-2020 Paulo Moura <pmoura@logtalk.org>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
________________________________________________________________________


% start by loading the example by choosing one of the plain Prolog files
% (you must quit and restart Logtalk for each testing scenario):

| ?- logtalk_load(bench(loader)).
...

| ?- ['$LOGTALKUSER/examples/bench/boyer.pl'].
yes


% load the "lgtunit" tool so that we can use its benchmark predicates:

| ?- logtalk_load(lgtunit(loader)).
...


% benchmark both the plain Prolog and the Logtalk versions:

| ?- lgtunit::benchmark(top,1000,Time).
Time = ...
yes

| ?- lgtunit::benchmark(boyer::top,1000,Time).
Time = ...
yes

% for accurate timings of compiled ::/2 goals, the lgtunit::benchmark/3
% calls should be made from compiled code in order to avoid the top-level
% interpretation of the goals; an handy alternative is to use:

| ?- logtalk<<(lgtunit::benchmark(boyer::top,1000,Time)).
Time = ...
yes


% some Prolog compilers such as SWI-Prolog and YAP provide a handy time/1
% predicate that may also be used in alternative to the `lgtunit` benchmark
% predicates (the adapter files for these two systems ensure that ::/2 goals
% in the argument of the time/1 are fully compiled prior to calling them so
% that we benchmark the code instead of the compiler):

| ?- time(true).  % autoload if necessary
...

| ?- time((between(1,1000,_),top,fail;true)).
...

| ?- time((between(1,1000,_),boyer::top,fail;true)).
...
