| 
									
										
										
										
											2007-06-12 10:39:47 +00:00
										 |  |  | ================================================================ | 
					
						
							|  |  |  | Logtalk - Open source object-oriented logic programming language | 
					
						
							| 
									
										
										
										
											2007-11-06 01:50:09 +00:00
										 |  |  | Release 2.30.7 | 
					
						
							| 
									
										
										
										
											2004-10-25 11:13:58 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-01-10 12:46:10 +00:00
										 |  |  | Copyright (c) 1998-2007 Paulo Moura.  All Rights Reserved. | 
					
						
							| 
									
										
										
										
											2007-06-12 10:39:47 +00:00
										 |  |  | ================================================================ | 
					
						
							| 
									
										
										
										
											2004-10-25 11:13:58 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-11-29 20:36:31 +00:00
										 |  |  | To load this example and for sample queries, please see the SCRIPT file. | 
					
						
							| 
									
										
										
										
											2004-10-25 11:13:58 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-22 23:57:45 +00:00
										 |  |  | This folder provides simple benchmark tests for comparing Logtalk message  | 
					
						
							|  |  |  | sending performance with direct predicates calls in plain Prolog. | 
					
						
							|  |  |  | These benchmarks may also be used for comparing Logtalk message sending  | 
					
						
							|  |  |  | performance across Prolog compilers. | 
					
						
							| 
									
										
										
										
											2004-10-25 11:13:58 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-12 10:39:47 +00:00
										 |  |  | This example is made of four loader files and five source files: | 
					
						
							| 
									
										
										
										
											2004-10-25 11:13:58 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-12 10:39:47 +00:00
										 |  |  | 	loader_events.lgt | 
					
						
							|  |  |  | 		loads all source files with event support turned on | 
					
						
							|  |  |  | 	loader_no_events.lgt | 
					
						
							|  |  |  | 		loads all source files with event support turned off | 
					
						
							|  |  |  | 	loader_static_binding.lgt | 
					
						
							|  |  |  | 		loads all source files with event support turned off and using | 
					
						
							|  |  |  | 		static binding | 
					
						
							|  |  |  | 	loader.lgt | 
					
						
							|  |  |  | 		the same as the loader_static_binding.lgt file | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	benchmarks.lgt | 
					
						
							|  |  |  | 		contains the benchmark goals and testing predicates | 
					
						
							| 
									
										
										
										
											2005-04-22 23:57:45 +00:00
										 |  |  | 	plain.lgt | 
					
						
							| 
									
										
										
										
											2005-03-06 21:19:09 +00:00
										 |  |  | 		contains a definition for a list length predicate and a predicate  | 
					
						
							|  |  |  | 		for testing performance of the built-in predicates assertz/1 and  | 
					
						
							|  |  |  | 		retract/1 | 
					
						
							| 
									
										
										
										
											2005-04-22 23:57:45 +00:00
										 |  |  | 	module.pl (not loaded by default; see below) | 
					
						
							| 
									
										
										
										
											2004-10-25 11:13:58 +00:00
										 |  |  | 		contains the same definition of a list length predicate  | 
					
						
							|  |  |  | 		encapsulated in a module | 
					
						
							| 
									
										
										
										
											2007-06-12 10:39:47 +00:00
										 |  |  | 	objects.lgt | 
					
						
							|  |  |  | 		contains an object encapsulating the same definition of a list    | 
					
						
							|  |  |  | 		length predicate, plus two descendant objects to simulate a small  | 
					
						
							|  |  |  | 		hierarchy (used for testing calls to imported category predicates) | 
					
						
							| 
									
										
										
										
											2005-03-06 21:19:09 +00:00
										 |  |  | 	database.lgt | 
					
						
							|  |  |  | 		contains predicates for testing the performance of the built-in  | 
					
						
							|  |  |  | 		database methods assertz/1 and retract/1 | 
					
						
							| 
									
										
										
										
											2007-06-12 10:39:47 +00:00
										 |  |  | 	category.lgt | 
					
						
							|  |  |  | 		contains a single predicate used when comparing performance of | 
					
						
							|  |  |  | 		calls to imported category predicates using direct calls and using  | 
					
						
							|  |  |  | 		messages to "self" | 
					
						
							| 
									
										
										
										
											2005-03-06 21:19:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-04-22 23:57:45 +00:00
										 |  |  | You may have noticed above that the benchmark predicates and the predicates  | 
					
						
							|  |  |  | for plain Prolog testing are both encapsulated in Logtalk source files. The  | 
					
						
							|  |  |  | Logtalk compiler just copies the plain Prolog code to the generated Prolog  | 
					
						
							| 
									
										
										
										
											2007-06-12 10:39:47 +00:00
										 |  |  | files. The reason for using the .lgt extension for these files is simply to  | 
					
						
							|  |  |  | make it possible to load all the example code using calls to the predicates  | 
					
						
							|  |  |  | logtalk_load/1-2. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | By default, the benchmark tests on the SCRIPT file use a list of 20 elements  | 
					
						
							|  |  |  | as an argument to the list length predicates. When dynamic binding is used,  | 
					
						
							|  |  |  | increasing the list length leads to decreasing performance differences between  | 
					
						
							|  |  |  | plain Prolog and Logtalk as the list length computation time far outweighs the | 
					
						
							|  |  |  | overhead of the message sending mechanism. Likewise, decreasing the list  | 
					
						
							|  |  |  | length leads to increasing performance differences between plain Prolog and  | 
					
						
							|  |  |  | Logtalk (up to the point you will be measuring the Logtalk message sending  | 
					
						
							|  |  |  | mechanism overhead compared to plain Prolog predicate calls). In real-life  | 
					
						
							|  |  |  | applications, only testing can give you a balanced view on the trade-offs  | 
					
						
							|  |  |  | between plain Prolog performance and Logtalk programming features. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | By default, the loader files used to load the example code do not load the  | 
					
						
							|  |  |  | module.pl file. Edit these files if your Prolog compiler supports a module | 
					
						
							| 
									
										
										
										
											2005-04-22 23:57:45 +00:00
										 |  |  | system and you want to run some comparative performance tests between plain  | 
					
						
							|  |  |  | Prolog, Prolog modules, and Logtalk objects. Note that you may need to edit  | 
					
						
							|  |  |  | the code on the module.pl file to make any necessary compatibility changes  | 
					
						
							|  |  |  | for your Prolog compiler module system. For most Prolog module systems, the  | 
					
						
							|  |  |  | performance of module calls is close or even identical to the performance of  | 
					
						
							| 
									
										
										
										
											2007-06-12 10:39:47 +00:00
										 |  |  | plain Prolog calls when using imported predicates and implicit qualification. | 
					
						
							|  |  |  | When using explicit module qualification, performance can be significantly  | 
					
						
							|  |  |  | worse. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | When static binding is used, messages to objects are, whenever possible,  | 
					
						
							|  |  |  | translated to direct predicate calls. Thus performance should be about the  | 
					
						
							|  |  |  | same as in plain Prolog predicate calls. However, due to the overhead of  | 
					
						
							|  |  |  | three extra arguments per object predicate (used for passing the execution  | 
					
						
							|  |  |  | context), the performance of Logtalk optimized calls might be slightly  | 
					
						
							|  |  |  | worse than the equivalent plain Prolog predicate calls. |