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 ;; complexity. 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 (parse-time str)
42 (and (char-numeric? (string-ref str 0))
43 (fold (lambda (x ret) (+ (* ret 60) x)) 0
44 (map (lambda (x) (with-input-from-string x read))
45 (string-split str #\:)))))
47 (define (run-test program . args)
48 (format #t "; running test: ~a\n" (cons program args))
56 (string-join (map object->string (cons program args)) " "))))))
58 (define (seq start stop step)
59 (let lp ((n start) (out '()))
62 (lp (+ n step) (cons n out)))))
64 (define (run-tests n-elements)
65 (let lp ((x 1) (out '()))
69 (acons x (run-test "./complexity" x n-elements) out)))))
71 (define (output-results results)
72 (let ((p (open-output-file "complexity.data")))
73 (display "#complexity creation state-change run destroy\n" p)
76 (display (car line) p)
78 (lambda (t) (format p " ~a" t))
85 (apply run-tests (map string->number (cdr (program-arguments)))))