| 
									
										
										
										
											2008-02-12 16:51:34 -05:00
										 |  |  | ! Copyright (C) 2007, 2008 Slava Pestov. | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2008-03-12 20:55:06 -04:00
										 |  |  | USING: kernel vocabs vocabs.loader tools.time tools.vocabs | 
					
						
							| 
									
										
										
										
											2008-02-12 16:51:34 -05:00
										 |  |  | arrays assocs io.styles io help.markup prettyprint sequences | 
					
						
							| 
									
										
										
										
											2008-11-24 06:46:43 -05:00
										 |  |  | continuations debugger math ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | IN: benchmark | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : run-benchmark ( vocab -- result )
 | 
					
						
							| 
									
										
										
										
											2008-12-10 02:12:08 -05:00
										 |  |  |     [ "=== " write vocab-name print flush ] [ | 
					
						
							|  |  |  |         [ [ require ] [ [ run ] benchmark ] bi ] curry
 | 
					
						
							|  |  |  |         [ error. f ] recover
 | 
					
						
							|  |  |  |     ] bi ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : run-benchmarks ( -- assoc )
 | 
					
						
							| 
									
										
										
										
											2008-11-06 14:13:47 -05:00
										 |  |  |     "benchmark" all-child-vocabs-seq | 
					
						
							|  |  |  |     [ dup run-benchmark ] { } map>assoc ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : benchmarks. ( assoc -- )
 | 
					
						
							|  |  |  |     standard-table-style [ | 
					
						
							|  |  |  |         [ | 
					
						
							|  |  |  |             [ "Benchmark" write ] with-cell | 
					
						
							| 
									
										
										
										
											2008-11-24 06:46:43 -05:00
										 |  |  |             [ "Time (seconds)" write ] with-cell | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  |         ] with-row | 
					
						
							|  |  |  |         [ | 
					
						
							|  |  |  |             [ | 
					
						
							| 
									
										
										
										
											2008-03-13 04:35:54 -04:00
										 |  |  |                 [ [ 1array $vocab-link ] with-cell ] | 
					
						
							| 
									
										
										
										
											2009-03-16 00:25:36 -04:00
										 |  |  |                 [ [ 1000000 /f pprint-cell ] [ [ "failed" write ] with-cell ] if* ] bi*
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  |             ] with-row | 
					
						
							|  |  |  |         ] assoc-each
 | 
					
						
							| 
									
										
										
										
											2009-03-16 00:25:36 -04:00
										 |  |  |     ] tabular-output nl ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : benchmarks ( -- )
 | 
					
						
							|  |  |  |     run-benchmarks benchmarks. ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | MAIN: benchmarks | 
					
						
							|  |  |  | 
 |