6 ;; Quick hack to make some data files that gnuplot can read from
7 ;; mass-elements. Guile 1.6.
9 (use-modules (srfi srfi-13)
14 (define *phases* '(create set run destroy))
16 (define (read-lines port)
18 (let ((x (read-line port)))
23 (lp (cons x lines))))))
25 (define (run-test n-identities)
26 (format #t "; running test: ~a\n" n-identities)
27 (let lp ((in (read-lines
29 (format #f "./mass_elements ~A"
30 (number->string n-identities)))))
34 (or (eq? (length out) 4) (error "Invalid mass_elements output"))
35 (map cons *phases* (reverse! out)))
36 (let ((line (car in)))
37 (if (eqv? (string-ref line 0) #\*)
40 (cons (fold (lambda (x ret) (+ (* ret 60) x)) 0
41 (map (lambda (x) (with-input-from-string x read))
42 (string-split line #\:)))
45 (define (run-tests start stop step)
46 (let lp ((n start) (out '()))
50 (acons n (run-test n) out)))))
52 (define (output-results results)
53 (let ((p (open-output-file "mass_elements.data")))
54 (display "#num_identities creation state-change run destroy\n" p)
55 (let lp ((in results))
57 (let* ((line (car in))
61 (lambda (t) (format p " ~a" t))
68 (apply run-tests (map string->number (cdr (program-arguments)))))