db4
Slava Pestov 2008-05-07 21:54:41 -05:00
parent b8e691297d
commit 1cbe87da82
3 changed files with 16 additions and 19 deletions

View File

@ -36,6 +36,7 @@ IN: tools.memory
[ first2 ] [ number>string "Generation " prepend ] bi* [ first2 ] [ number>string "Generation " prepend ] bi*
write-total/used/free write-total/used/free
] 2each ] 2each
"Decks" write-total
"Cards" write-total ; "Cards" write-total ;
: write-labelled-size ( n string -- ) : write-labelled-size ( n string -- )

View File

@ -20,14 +20,6 @@ HELP: benchmark
HELP: time HELP: time
{ $values { "quot" "a quotation" } } { $values { "quot" "a quotation" } }
{ $description "Runs a quotation and then prints the total run time and time spent in the garbage collector." } { $description "Runs a quotation and then prints the total run time and some garbage collection statistics." } ;
{ $examples
"This word can be used to compare performance of the non-optimizing and optimizing compilers."
$nl
"First, we time a quotation directly; quotations are compiled by the non-optimizing quotation compiler:"
{ $unchecked-example "[ 1000000 0 [ + ] reduce drop ] time" "1116 ms run / 6 ms GC time" }
"Now we define a word and compile it with the optimizing word compiler. This results is faster execution:"
{ $unchecked-example ": foo 1000000 0 [ + ] reduce ;" "\\ foo compile" "[ foo drop ] time" "202 ms run / 13 ms GC time" }
} ;
{ gc-time benchmark millis time } related-words { benchmark millis time } related-words

View File

@ -9,15 +9,19 @@ IN: tools.time
: stats. ( data -- ) : stats. ( data -- )
{ {
"Run time" "Run time (ms):"
"GC time" "Nursery GC time (ms):"
"Nursery collections" "Nursery GC #:"
"Aging collections" "Aging GC time (ms):"
"Tenured collections" "Aging GC #:"
"Cards checked" "Tenured GC time (ms):"
"Cards scanned" "Tenured GC #:"
"Code literal collections" "Cards scanned:"
} swap zip [ nip 0 > ] assoc-filter "Decks scanned:"
"Code literal GC #:"
"Bytes copied:"
"Bytes collected:"
} swap zip
standard-table-style [ standard-table-style [
[ [
[ [