| 
									
										
										
										
											2001-06-06 19:40:57 +00:00
										 |  |  | ================================================================= | 
					
						
							|  |  |  | Logtalk - Object oriented extension to Prolog | 
					
						
							| 
									
										
										
										
											2002-11-04 21:29:14 +00:00
										 |  |  | Release 2.14.4 | 
					
						
							| 
									
										
										
										
											2001-06-06 19:40:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-01-08 00:05:10 +00:00
										 |  |  | Copyright (c) 1998-2002 Paulo Moura.  All Rights Reserved. | 
					
						
							| 
									
										
										
										
											2001-06-06 19:40:57 +00:00
										 |  |  | ================================================================= | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | %% message_counter example | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | % choose an object to spy: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | | ?- message_counter::set_spy_point(_, list, _, _). | 
					
						
							|  |  |  | yes | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | % activate the monitor: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | | ?- message_counter::activate_monitor. | 
					
						
							|  |  |  | yes | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | % send some messages to the spied object; get all the answers for ancestor/1: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | | ?- list::empty([]). | 
					
						
							|  |  |  | yes | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | | ?- list::member(X, [1, 2, 3]). | 
					
						
							|  |  |  | X = 1 ? ; | 
					
						
							|  |  |  | X = 2 ? ; | 
					
						
							|  |  |  | X = 3 ? ; | 
					
						
							|  |  |  | no | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | % print a report of the data collected by the monitor: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | | ?- message_counter::report. | 
					
						
							|  |  |  | list | 
					
						
							|  |  |  |   total of calls: 2 | 
					
						
							|  |  |  |   total of exits: 4 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   empty/1 | 
					
						
							|  |  |  |     calls: 1 | 
					
						
							|  |  |  |     exits: 1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   member/2 | 
					
						
							|  |  |  |     calls: 1 | 
					
						
							|  |  |  |     exits: 3 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | yes | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | % stop and reset the message counter monitor: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | | ?- message_counter::stop. | 
					
						
							|  |  |  | yes | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | %% stop_watch example | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | % choose a pair object/message to spy: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | | ?- stop_watch::set_spy_point(_, list, length(_, _), _). | 
					
						
							|  |  |  | yes | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | % activate the monitor: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | | ?- stop_watch::activate_monitor. | 
					
						
							|  |  |  | yes | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | % send a message to the spied object: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | | ?- list::length([1, 2, 3], Length). | 
					
						
							|  |  |  | list <-- length([1,2,3],_277) from user | 
					
						
							|  |  |  | STARTING at 755.75999999999999 seconds | 
					
						
							|  |  |  | list <-- length([1,2,3],3) from user | 
					
						
							|  |  |  | ENDING at 755.69000000000005 seconds | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Length = 3 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | yes | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | % clean up: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | | ?- stop_watch::reset_monitor. | 
					
						
							|  |  |  | yes | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | %% timer example | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | % try a message 1000 times and return the average time: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | | ?- timer::timer(list::length([1, 2, 3], _), 1000, Time). | 
					
						
							| 
									
										
										
										
											2002-04-03 13:26:59 +00:00
										 |  |  | Time = 0.00008 | 
					
						
							| 
									
										
										
										
											2001-06-06 19:40:57 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | yes |