| 
									
										
										
										
											2009-09-27 16:11:21 -04:00
										 |  |  | USING: alien.c-types sequences kernel math specialized-arrays | 
					
						
							|  |  |  | fry ;
 | 
					
						
							| 
									
										
										
										
											2009-09-09 23:33:34 -04:00
										 |  |  | SPECIALIZED-ARRAY: int | 
					
						
							| 
									
										
										
										
											2008-09-03 08:25:34 -04:00
										 |  |  | IN: benchmark.dawes | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! Phil Dawes's performance problem | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-03 07:21:02 -05:00
										 |  |  | : count-ones ( int-array -- n ) [ 1 = ] count ; inline
 | 
					
						
							| 
									
										
										
										
											2008-09-03 08:25:34 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-03 07:21:02 -05:00
										 |  |  | : make-int-array ( -- int-array )
 | 
					
						
							| 
									
										
										
										
											2017-06-01 17:59:35 -04:00
										 |  |  |     120000 <iota> [ 255 bitand ] int-array{ } map-as ; inline
 | 
					
						
							| 
									
										
										
										
											2008-09-03 08:25:34 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : dawes-benchmark ( -- )
 | 
					
						
							| 
									
										
										
										
											2009-09-09 23:33:34 -04:00
										 |  |  |     200 make-int-array '[ _ count-ones ] replicate drop ;
 | 
					
						
							| 
									
										
										
										
											2008-09-03 08:25:34 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | MAIN: dawes-benchmark |