Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 23 |
Nodes: | 6 (0 / 6) |
Uptime: | 49:50:46 |
Calls: | 583 |
Files: | 1,138 |
Messages: | 111,303 |
(running small "scripts" 100 times and histogramming the results), and I needed to sum the "user" and "system" times reported by the "csh" builtin "time" command (since the "total" time has one fewer digits of precision). Here's what I wrote:
#!/usr/local/bin/cmucl -script
;;; Script to sum the first two times in a "csh" "time" output:
;;; 0.046u 0.007s 0:00.06 66.6% 147+3008k 0+0io 0pf+0w
(defun sum-u-s (line)
(+ (read-from-string line nil nil :start 0 :end (position #\u line))
(read-from-string line nil nil :start (1+ (position #\space line))
:end (position #\s line))))
(loop for line = (read-line *standard-input* nil nil)
while line
do (format t "~5,3f~%" (sum-u-s line)))
Trivial? Yes, but it's what I needed at the moment, and it was the
language I wa able to do it in fastest.
Rob Warnock wrote:
(running small "scripts" 100 times and histogramming the results), and I needed to sum the "user" and "system" times reported by the "csh" builtin "time" command (since the "total" time has one fewer digits of precision). Here's what I wrote:
#!/usr/local/bin/cmucl -script
;;; Script to sum the first two times in a "csh" "time" output:
;;; 0.046u 0.007s 0:00.06 66.6% 147+3008k 0+0io 0pf+0w
(defun sum-u-s (line)
(+ (read-from-string line nil nil :start 0 :end (position #\u line))
(read-from-string line nil nil :start (1+ (position #\space line))
:end (position #\s line))))
(loop for line = (read-line *standard-input* nil nil)
while line
do (format t "~5,3f~%" (sum-u-s line)))
Trivial? Yes, but it's what I needed at the moment, and it was the
language I wa able to do it in fastest.
Gauche Scheme:
(until (read-line) eof-object? => line
(with-input-from-string (regexp-replace-all #/[us]/ line "")
(cut print (+ (read) (read)))))