]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/time/time.factor
Removing more >r/r> usages
[factor.git] / basis / tools / time / time.factor
1 ! Copyright (C) 2003, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel math math.vectors memory io io.styles prettyprint
4 namespaces system sequences splitting grouping assocs strings ;
5 IN: tools.time
6
7 : benchmark ( quot -- runtime )
8     micros [ call micros ] dip - ; inline
9
10 : time. ( data -- )
11     unclip
12     "==== RUNNING TIME" print nl 1000000 /f pprint " seconds" print nl
13     4 cut*
14     "==== GARBAGE COLLECTION" print nl
15     [
16         6 group
17         {
18             "GC count:"
19             "Cumulative GC time (us):"
20             "Longest GC pause (us):"
21             "Average GC pause (us):"
22             "Objects copied:"
23             "Bytes copied:"
24         } prefix
25         flip
26         { "" "Nursery" "Aging" "Tenured" } prefix
27         simple-table.
28     ]
29     [
30         nl
31         {
32             "Total GC time (us):"
33             "Cards scanned:"
34             "Decks scanned:"
35             "Code heap literal scans:"
36         } swap zip simple-table.
37     ] bi* ;
38
39 : time ( quot -- )
40     gc-reset micros [ call gc-stats micros ] dip - prefix time. ; inline