Fix tools.time output in the TTY listener
parent
b20ed595c4
commit
f51b7b2677
|
@ -99,7 +99,11 @@ M: plain-writer make-block-stream
|
|||
nip <ignore-close-stream> ;
|
||||
|
||||
M: plain-writer stream-write-table
|
||||
[ drop format-table [ nl ] [ write ] interleave ] with-output-stream* ;
|
||||
[
|
||||
drop
|
||||
[ [ >string ] map ] map format-table
|
||||
[ nl ] [ write ] interleave
|
||||
] with-output-stream* ;
|
||||
|
||||
M: plain-writer make-cell-stream 2drop <string-writer> ;
|
||||
|
||||
|
|
|
@ -2,3 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: tools.test strings.tables ;
|
||||
IN: strings.tables.tests
|
||||
|
||||
[ { "A BB" "CC D" } ] [ { { "A" "BB" } { "CC" "D" } } format-table ] unit-test
|
||||
|
||||
[ { "A C" "B " "D E" } ] [ { { "A\nB" "C" } { "D" "E" } } format-table ] unit-test
|
|
@ -1,21 +1,30 @@
|
|||
! Copyright (C) 2009 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel sequences fry math.order ;
|
||||
USING: kernel sequences fry math.order splitting ;
|
||||
IN: strings.tables
|
||||
|
||||
<PRIVATE
|
||||
|
||||
: format-column ( seq ? -- seq )
|
||||
[
|
||||
dup [ length ] [ max ] map-reduce
|
||||
'[ _ CHAR: \s pad-tail ] map
|
||||
] unless ;
|
||||
|
||||
: map-last ( seq quot -- seq )
|
||||
[ dup length <reversed> ] dip '[ 0 = @ ] 2map ; inline
|
||||
|
||||
: max-length ( seq -- n )
|
||||
[ length ] [ max ] map-reduce ;
|
||||
|
||||
: format-row ( seq ? -- seq )
|
||||
[
|
||||
dup max-length
|
||||
'[ _ "" pad-tail ] map
|
||||
] unless ;
|
||||
|
||||
: format-column ( seq ? -- seq )
|
||||
[
|
||||
dup max-length
|
||||
'[ _ CHAR: \s pad-tail ] map
|
||||
] unless ;
|
||||
|
||||
PRIVATE>
|
||||
|
||||
: format-table ( table -- seq )
|
||||
flip [ format-column ] map-last
|
||||
flip [ " " join ] map ;
|
||||
[ [ [ string-lines ] map ] dip format-row flip ] map-last concat
|
||||
flip [ format-column ] map-last flip [ " " join ] map ;
|
|
@ -9,18 +9,19 @@ IN: tools.time
|
|||
micros [ call micros ] dip - ; inline
|
||||
|
||||
: time. ( time -- )
|
||||
"== Running time ==" print nl 1000000 /f pprint " seconds" write ;
|
||||
"== Running time ==" print nl 1000000 /f pprint " seconds" print ;
|
||||
|
||||
: gc-stats. ( stats -- )
|
||||
5 cut*
|
||||
"== Garbage collection ==" print nl
|
||||
"Times are in microseconds." print nl
|
||||
[
|
||||
6 group
|
||||
{
|
||||
"GC count:"
|
||||
"Cumulative GC time (us):"
|
||||
"Longest GC pause (us):"
|
||||
"Average GC pause (us):"
|
||||
"Total GC time:"
|
||||
"Longest GC pause:"
|
||||
"Average GC pause:"
|
||||
"Objects copied:"
|
||||
"Bytes copied:"
|
||||
} prefix
|
||||
|
@ -31,10 +32,10 @@ IN: tools.time
|
|||
[
|
||||
nl
|
||||
{
|
||||
"Total GC time (us):"
|
||||
"Total GC time:"
|
||||
"Cards scanned:"
|
||||
"Decks scanned:"
|
||||
"Card scan time (us):"
|
||||
"Card scan time:"
|
||||
"Code heap literal scans:"
|
||||
} swap zip simple-table.
|
||||
] bi* ;
|
||||
|
|
Loading…
Reference in New Issue