root/trunk/examples/benchmarks/NOTES.txt

Revision 4662, 4.3 KB (checked in by pmoura, 6 days ago)

Updated copyright notice.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1================================================================
2Logtalk - Open source object-oriented logic programming language
3Release 2.35.0
4
5Copyright (c) 1998-2009 Paulo Moura.        All Rights Reserved.
6Logtalk is free software.  You can redistribute it and/or modify
7it under the terms of the "Artistic License 2.0" as published by
8The Perl Foundation. Consult the "LICENSE.txt" file for details.
9================================================================
10
11
12To load this example and for sample queries, please see the SCRIPT.txt file.
13
14This folder provides simple benchmark tests for comparing Logtalk message
15sending performance with direct predicates calls in plain Prolog.
16These benchmarks may also be used for comparing Logtalk message sending
17performance across Prolog compilers.
18
19This example is made of four loader files and five source files:
20
21    loader_events.lgt
22        loads all source files with event support turned on
23    loader_no_events.lgt
24        loads all source files with event support turned off
25    loader_static_binding.lgt
26        loads all source files with event support turned off and using
27        static binding
28    loader.lgt
29        the same as the loader_static_binding.lgt file
30
31    benchmarks.lgt
32        contains the benchmark goals and testing predicates
33    plain.lgt
34        contains a definition for a list length predicate and a predicate
35        for testing performance of the built-in predicates assertz/1 and
36        retract/1
37    module.pl (not loaded by default; see below)
38        contains the same definition of a list length predicate
39        encapsulated in a module
40    objects.lgt
41        contains an object encapsulating the same definition of a list   
42        length predicate, plus two descendant objects to simulate a small
43        hierarchy (used for testing calls to imported category predicates)
44    database.lgt
45        contains predicates for testing the performance of the built-in
46        database methods assertz/1 and retract/1
47    category.lgt
48        contains a single predicate used when comparing performance of
49        calls to imported category predicates using direct calls and using
50        messages to "self"
51
52You may have noticed above that the benchmark predicates and the predicates
53for plain Prolog testing are both encapsulated in Logtalk source files. The
54Logtalk compiler just copies the plain Prolog code to the generated Prolog
55files. The reason for using the .lgt extension for these files is simply to
56make it possible to load all the example code using calls to the predicates
57logtalk_load/1-2.
58
59By default, the benchmark tests on the SCRIPT file use a list of 20 elements
60as an argument to the list length predicates. When dynamic binding is used,
61increasing the list length leads to decreasing performance differences between
62plain Prolog and Logtalk as the list length computation time far outweighs the
63overhead of the message sending mechanism. Likewise, decreasing the list
64length leads to increasing performance differences between plain Prolog and
65Logtalk (up to the point you will be measuring the Logtalk message sending
66mechanism overhead compared to plain Prolog predicate calls). In real-life
67applications, only testing can give you a balanced view on the trade-offs
68between plain Prolog performance and Logtalk programming features.
69
70By default, the loader files used to load the example code do not load the
71module.pl file. Edit these files if your Prolog compiler supports a module
72system and you want to run some comparative performance tests between plain
73Prolog, Prolog modules, and Logtalk objects. Note that you may need to edit
74the code on the module.pl file to make any necessary compatibility changes
75for your Prolog compiler module system. For most Prolog module systems, the
76performance of module calls is close or even identical to the performance of
77plain Prolog calls when using imported predicates and implicit qualification.
78When using explicit module qualification, performance can be significantly
79worse.
80
81When static binding is used, messages to objects are, whenever possible,
82translated to direct predicate calls. Thus performance should be about the
83same as in plain Prolog predicate calls. However, due to the overhead of
84three extra arguments per object predicate (used for passing the execution
85context), the performance of Logtalk optimized calls might be slightly
86worse than the equivalent plain Prolog predicate calls.
Note: See TracBrowser for help on using the browser.