* update guile-stats functions a bit
This commit is contained in:
@ -132,7 +132,7 @@ that match it."
|
|||||||
(mu:stats:top-n
|
(mu:stats:top-n
|
||||||
(lambda (msg) (mu:msg:subject msg)) N EXPR))
|
(lambda (msg) (mu:msg:subject msg)) N EXPR))
|
||||||
|
|
||||||
(define (mu:stats:table pairs)
|
(define* (mu:stats:table pairs #:optional (port (current-output-port)))
|
||||||
"display a list of PAIRS in a table-like fashion"
|
"display a list of PAIRS in a table-like fashion"
|
||||||
(let ((maxlen 0))
|
(let ((maxlen 0))
|
||||||
(for-each ;; find the widest in the first col
|
(for-each ;; find the widest in the first col
|
||||||
@ -144,17 +144,12 @@ that match it."
|
|||||||
(let ((first (format #f "~s" (car pair)))
|
(let ((first (format #f "~s" (car pair)))
|
||||||
(second (format #f "~s" (cdr pair))))
|
(second (format #f "~s" (cdr pair))))
|
||||||
(display (format #f "~A~v_~A\n"
|
(display (format #f "~A~v_~A\n"
|
||||||
first (- maxlen (string-length first)) second))))
|
first (- maxlen (string-length first)) second) port)))
|
||||||
pairs)))
|
pairs)))
|
||||||
|
|
||||||
(define (mu:stats:plot pairs)
|
(define (mu:stats:export pairs)
|
||||||
"plot a table using gnuplot"
|
"export pairs to a temporary file, return its name"
|
||||||
;; create a tmpfile with the data...
|
|
||||||
(let* ((datafile (tmpnam))
|
(let* ((datafile (tmpnam))
|
||||||
(output (open datafile (logior O_CREAT O_WRONLY) #O0644)))
|
(output (open datafile (logior O_CREAT O_WRONLY) #O0644)))
|
||||||
(for-each
|
(mu:stats:table pairs output)
|
||||||
(lambda (pair) (display (format #f "~A ~A\n" (car pair) (cdr pair)) output))
|
datafile))
|
||||||
pairs)
|
|
||||||
(close-output-port output)
|
|
||||||
;; now, display it.
|
|
||||||
(system (format #f "gnuplot -p -e 'plot \"~A\" w boxes fs pattern 2'" datafile))))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user