6 ;; Copyright (C) 2005 Andy Wingo
8 ;; This library is free software; you can redistribute it and/or
9 ;; modify it under the terms of the GNU Lesser General Public
10 ;; License as published by the Free Software Foundation; either
11 ;; version 2.1 of the License, or (at your option) any later version.
13 ;; This library is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 ;; Lesser General Public License for more details.
18 ;; You should have received a copy of the GNU Lesser General Public
19 ;; License along with this library; if not, write to the Free Software
20 ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 ;; Quick hack to make some data files that gnuplot can read from
23 ;; mass-elements. Guile 1.6.
25 (use-modules (srfi srfi-13)
30 (define *phases* '(create set run destroy))
32 (define (read-lines port)
34 (let ((x (read-line port)))
39 (lp (cons x lines))))))
41 (define (run-test n-identities)
42 (format #t "; running test: ~a\n" n-identities)
43 (let lp ((in (read-lines
45 (format #f "./mass-elements ~A"
46 (number->string n-identities)))))
50 (or (eq? (length out) 4) (error "Invalid mass_elements output"))
51 (map cons *phases* (reverse! out)))
52 (let ((line (car in)))
53 (if (eqv? (string-ref line 0) #\*)
56 (cons (fold (lambda (x ret) (+ (* ret 60) x)) 0
57 (map (lambda (x) (with-input-from-string x read))
58 (string-split line #\:)))
61 (define (run-tests start stop step)
62 (let lp ((n start) (out '()))
66 (acons n (run-test n) out)))))
68 (define (output-results results)
69 (let ((p (open-output-file "mass_elements.data")))
70 (display "#num_identities creation state-change run destroy\n" p)
71 (let lp ((in results))
73 (let* ((line (car in))
77 (lambda (t) (format p " ~a" t))
84 (apply run-tests (map string->number (cdr (program-arguments)))))