2009-11-05 02:07:59 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								USING: help.markup help.syntax memory system tools.dispatch
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								tools.memory quotations vm ;
							 | 
						
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								IN: tools.time
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-05 02:07:59 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								ARTICLE: "timing" "Timing code and collecting statistics"
							 | 
						
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								"You can time the execution of a quotation in the listener:"
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{ $subsections time }
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-05 02:07:59 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								"This word also collects statistics about method dispatch and garbage collection:"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{ $subsections dispatch-stats. gc-events. gc-stats. gc-summary. }
							 | 
						
					
						
							
								
									
										
										
										
											2011-01-17 17:28:40 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								"A lower-level word puts timings on the stack, instead of printing:"
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{ $subsections benchmark }
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-21 18:46:27 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								"You can also read the system clock directly; see " { $link "system" } "."
							 | 
						
					
						
							
								
									
										
										
										
											2011-11-10 15:32:43 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{ $see-also "tools.profiler.sampling" "tools.annotations" "calendar" } ;
							 | 
						
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								ABOUT: "timing"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								HELP: benchmark
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-05 02:07:59 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{ $values { "quot" quotation }
							 | 
						
					
						
							
								
									
										
										
										
											2010-08-11 22:20:37 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          { "runtime" "the runtime in nanoseconds" } }
							 | 
						
					
						
							
								
									
										
										
										
											2008-05-10 16:23:49 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      { $description "Runs a quotation, measuring the total wall clock time." }
							 | 
						
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{ $notes "A nicer word for interactive use is " { $link time } "." } ;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								HELP: time
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-05 02:07:59 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{ $values { "quot" quotation } }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{ $description "Runs a quotation, gathering statistics about method dispatch and garbage collection, and then prints the total run time." } ;
							 | 
						
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2010-06-22 03:04:31 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{ benchmark time } related-words
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-05 02:07:59 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								HELP: collect-gc-events
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-15 21:00:15 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{ $values { "quot" quotation } { "gc-events" "a sequence of " { $link gc-event } " instances" } }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{ $description "Calls the quotation and outputs a sequence of " { $link gc-event } " instances." }
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-05 02:07:59 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{ $notes "The " { $link time } " combinator automatically calls this combinator." } ;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								HELP: collect-dispatch-stats
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-15 23:44:36 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{ $values { "quot" quotation } { "dispatch-statistics" dispatch-statistics } }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{ $description "Calls the quotation and outputs a " { $link dispatch-statistics } " instance." }
							 | 
						
					
						
							
								
									
										
										
										
											2009-11-05 02:07:59 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{ $notes "The " { $link time } " combinator automatically calls this combinator." } ;
							 |