git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1973 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
		
			
				
	
	
		
			50 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| ================================================================
 | |
| Logtalk - Open source object-oriented logic programming language
 | |
| Release 2.30.7
 | |
| 
 | |
| Copyright (c) 1998-2007 Paulo Moura.  All Rights Reserved.
 | |
| ================================================================
 | |
| 
 | |
| 
 | |
| % start by loading the loading the example:
 | |
| 
 | |
| | ?- logtalk_load(primes(loader)).
 | |
| ...
 | |
| 
 | |
| 
 | |
| % NOTE: the example queries below use a SWI-Prolog proprietary predicate 
 | |
| % time/1 in order to get accurate goal times. For other Prolog compilers, 
 | |
| % replace the time/1 call by any appropriate timing calls (e.g. cputime/0).
 | |
| 
 | |
| 
 | |
| % calculate the prime numbers in a given interval using a single thread:
 | |
| 
 | |
| ?- time(primes(1)::primes(1, 500000, Primes)).
 | |
| % 67,657,287 inferences, 11.97 CPU in 12.27 seconds (98% CPU, 5652238 Lips)
 | |
| 
 | |
| Primes = [2, 3, 5, 7, 11, 13, 17, 19, 23|...] 
 | |
| 
 | |
| Yes
 | |
| 
 | |
| 
 | |
| % calculate the prime numbers in a given interval by splitting the interval 
 | |
| % in two sub-intervals and using a thread per sub-interval:
 | |
| 
 | |
| ?- time(primes(2)::primes(1, 500000, Primes)).
 | |
| % 77 inferences, 11.71 CPU in 7.50 seconds (156% CPU, 7 Lips)
 | |
| 
 | |
| Primes = [2, 3, 5, 7, 11, 13, 17, 19, 23|...] 
 | |
| 
 | |
| Yes
 | |
| 
 | |
| 
 | |
| % calculate the prime numbers in a given interval by splitting the interval 
 | |
| % in four sub-intervals and using a thread per sub-interval:
 | |
| 
 | |
| ?- time(primes(4)::primes(1, 500000, Primes)).
 | |
| % 129 inferences, 11.57 CPU in 3.99 seconds (290% CPU, 11 Lips)
 | |
| 
 | |
| Primes = [2, 3, 5, 7, 11, 13, 17, 19, 23|...] 
 | |
| 
 | |
| Yes
 |