Did you know ... Search Documentation:
Pack logtalk -- logtalk-3.77.0/examples/bench/SCRIPT.txt

This file is part of Logtalk https://logtalk.org/ SPDX-FileCopyrightText: 1998-2023 Paulo Moura <pmoura@logtalk.org> SPDX-License-Identifier: Apache-2.0

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:

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

% run all tests, repeating each one 1000 times:

| ?- run. ...

% run all tests, repeating each one N times, e.g. 2000 times:

| ?- run(2000). ...

% run a specific benchmark, e.g. "nreverse", 10000 times:

| ?- run(nreverse, 10000). ...

% if you want to compare Logtalk and plain Prolog versions of an individual % benchmark, load also its Prolog file (in this case, you must quit and % restart Logtalk for each testing scenario); for example:

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

% you can also use the "lgtunit" tool benchmark predicates directly; for % example:

| ?- 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 Logtalk compiler):

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

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

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