Debian Codegraph @

benchmarks.larceny/summarize.sch

raw
1 ; Extraction of benchmark results.
2
3 (define (summarize-usual-suspects . rest)
4 (let* ((setting (if (null? rest) "-r6rs" (car rest)))
5 (summarize
6 (lambda (system-results)
7 (lambda (in out)
8 ((summarize system-results)
9 (string-append in setting)
10 (string-append out setting))))))
11
12 ;((summarize bigloo-results) "results.Bigloo" "summary.Bigloo")
13 ;((summarize chez-results) "results.Chez-Scheme" "summary.Chez")
14 ((summarize ikarus-results) "results.Ikarus-Scheme" "summary.Ikarus")
15 ;((summarize chicken-results) "results.Chicken" "summary.Chicken")
16 ;((summarize gambit-results) "results.Gambit-C" "summary.Gambit")
17 ((summarize larceny-results) "results.Larceny" "summary.Larceny")
18 ;((summarize mzscheme-results) "results.MzScheme" "summary.MzScheme")
19 ;((summarize scheme48-results) "results.Scheme48" "summary.Scheme48")
20 ))
21
22 (define (decode-usual-suspects . rest)
23 (let* ((setting (if (null? rest) "-r6rs" (car rest)))
24 (decode-summary
25 (lambda (in)
26 (decode-summary (string-append in setting)))))
27 (map decode-summary
28 '("summary.Larceny"
29 ;"summary.Bigloo"
30 ;"summary.Chez"
31 ;"summary.Chicken"
32 ;"summary.Gambit"
33 "summary.Ikarus"
34 ;"summary.MzScheme"
35 ;"summary.Scheme48"
36 ))))
37
38 (define (summarize-usual-suspects-linux . rest)
39 (let* ((setting (if (null? rest) "-r6rs" (car rest)))
40 (summarize
41 (lambda (system-results)
42 (lambda (in out)
43 ((summarize system-results)
44 (string-append in setting)
45 (string-append out setting))))))
46
47 ((summarize bigloo-results) "results.Bigloo" "summary.Bigloo")
48 ((summarize chicken-results) "results.Chicken" "summary.Chicken")
49 ((summarize gambit-results) "results.Gambit-C" "summary.Gambit")
50 ((summarize henchman-results) "results.Henchman" "summary.Henchman")
51 ((summarize larceny-results) "results.Larceny" "summary.Larceny")
52 ((summarize mit-results) "results.MIT-Scheme" "summary.MIT")
53 ((summarize mzscheme-results) "results.MzScheme" "summary.MzScheme")
54 ((summarize ikarus-results) "results.Ikarus" "summary.Ikarus")
55 ((summarize petite-chez-results) "results.Petite-Chez-Scheme" "summary.Petite")
56 ((summarize scheme48-results) "results.Scheme48" "summary.Scheme48")))
57
58 (define (decode-usual-suspects-linux . rest)
59 (let* ((setting (if (null? rest) "-r6rs" (car rest)))
60 (decode-summary
61 (lambda (in)
62 (decode-summary (string-append in setting)))))
63 (map decode-summary
64 '(;"summary.Henchman"
65 "summary.Larceny"
66 ;"summary.Bigloo"
67 ;"summary.Chicken"
68 ;"summary.Gambit"
69 "summary.Ikarus"
70 ;"summary.MIT"
71 ;"summary.MzScheme"
72 ;"summary.Petite"
73 ;"summary.Scheme48"
74 ))))
75
76 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
77 ;
78 ; Help procedures.
79 ;
80 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
81
82 (define (readline port)
83 (do ((c (read-char port) (read-char port))
84 (chars '() (cons c chars)))
85 ((or (eof-object? c)
86 (char=? c #\newline))
87 (list->string (reverse chars)))))
88
89 (define (readlines port)
90 (do ((c (peek-char port) (peek-char port))
91 (lines '() (cons (readline port) lines)))
92 ((eof-object? c)
93 (reverse lines))))
94
95 ; If s1 is a substring of s2, then returns the least integer m
96 ; such that (string=? s1 (substring s2 m (+ m (string-length s1)))).
97 ; Otherwise returns #f.
98
99 (define (substring? s1 s2)
100 (let ((n1 (string-length s1))
101 (n2 (string-length s2)))
102 (let ((n (- n2 n1)))
103 (let loop ((m 0))
104 (if (<= m n)
105 (if (substring=? s1 s2 m (+ m n1))
106 m
107 (loop (+ m 1)))
108 #f)))))
109
110 (define (substring=? s1 s2 m n)
111 (and (<= (string-length s1) (- n m))
112 (<= n (string-length s2))
113 (do ((i 0 (+ i 1))
114 (m m (+ m 1)))
115 ((or (= m n)
116 (not (char=? (string-ref s1 i)
117 (string-ref s2 m))))
118 (= m n)))))
119
120 (define (right-justify x n . port)
121 (let ((p (open-output-string))
122 (port (if (null? port) (current-output-port) (car port))))
123 (display x p)
124 (let* ((s (get-output-string p))
125 (m (string-length s)))
126 (if (< m n)
127 (display (string-append (make-string (- n m) #\space) s) port)
128 (display (substring s 0 n) port)))))
129
130 (define (left-justify x n . port)
131 (let ((p (open-output-string))
132 (port (if (null? port) (current-output-port) (car port))))
133 (display x p)
134 (let* ((s (get-output-string p))
135 (m (string-length s)))
136 (if (< m n)
137 (display (string-append s (make-string (- n m) #\space)) port)
138 (display (substring s 0 n) port)))))
139
140 ; Given a string that contains a timing in hours:minutes:seconds
141 ; or in 1h3m0.417s format, returns the timing in milliseconds.
142
143 (define (string->msec s)
144 (if (substring? "s" s)
145 (string1->msec s)
146 (string2->msec s)))
147
148 (define (string1->msec s)
149 (let* ((s0 (list->string
150 (filter (lambda (c) (not (char-whitespace? c)))
151 (string->list s))))
152 (n1 (substring? "h" s0))
153 (s1 (if n1 (substring s0 0 n1) "0"))
154 (s0 (if n1 (substring s0 (+ n1 1) (string-length s0)) s0))
155 (n2 (substring? "m" s0))
156 (s2 (if n2 (substring s0 0 n2) "0"))
157 (s0 (if n2 (substring s0 (+ n2 1) (string-length s0)) s0))
158 (hours (if n1 (string->number s1) 0))
159 (minutes (if n2 (string->number s2) 0))
160 (seconds (string->number (substring s0 0 (- (string-length s0) 1))))
161 (seconds (+ (* 3600 hours) (* 60 minutes) seconds)))
162 (inexact->exact (round (* 1000.0 seconds)))))
163
164 (define (string2->msec s)
165 (let* ((s0 (list->string
166 (filter (lambda (c) (not (char-whitespace? c)))
167 (string->list s))))
168 (n1 (substring? ":" s0))
169 (s1 (if n1 (substring s0 0 n1) "0"))
170 (s0 (if n1 (substring s0 (+ n1 1) (string-length s0)) s0))
171 (n2 (substring? ":" s0))
172 (s2 (if n2 (substring s0 0 n2) "0"))
173 (s0 (if n2 (substring s0 (+ n2 1) (string-length s0)) s0))
174 (hours (if (and n1 n2) (string->number s1) 0))
175 (minutes (cond ((and n1 n2) (string->number s2))
176 (n1 (string->number s1))
177 (else 0)))
178 (seconds (string->number s0))
179 (seconds (+ (* 3600 hours) (* 60 minutes) seconds)))
180 (inexact->exact (round (* 1000.0 seconds)))))
181
182 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
183 ;
184 ; Summarizing the results.* files that are created by the bench
185 ; script.
186 ;
187 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
188
189 (define (summarize f)
190 (define (summarize in . rest)
191 (define (bad-arguments)
192 (error "Bad arguments to summarize-results"
193 (cons in rest)))
194 (cond ((string? in)
195 (call-with-input-file
196 in
197 (lambda (in) (apply summarize in rest))))
198 ((input-port? in)
199 (cond ((null? rest)
200 (summarize in (current-output-port)))
201 ((string? (car rest))
202 (call-with-output-file
203 (car rest)
204 (lambda (out)
205 (summarize in out))))
206 ((output-port? (car rest))
207 (f (readlines in) (car rest)))
208 (else
209 (bad-arguments))))
210 (else
211 (bad-arguments))))
212 summarize)
213
214 ; For results that are displayed in the form of
215 ; cpu time: 57290 real time: 58218
216
217 (define (generic-results sysname lines out)
218 (let ((system-key "Benchmarking ")
219 (test-key "Testing ")
220 (test-key-tail (string-append " under " sysname))
221 (cpu-key "cpu time: ")
222 (real-key " real time: ")
223 ;(gc-key " seconds in (major) GC")
224 ;(ms-key " ms")
225 (error-key "Error: ")
226 (wrong-key "*** wrong result ***"))
227 (let ((n-system-key (string-length system-key))
228 (n-test-key (string-length test-key))
229 (n-cpu-key (string-length cpu-key))
230 (n-real-key (string-length real-key))
231 ;(n-gc-key (string-length gc-key))
232 ;(n-ms-key (string-length ms-key))
233 (n-error-key (string-length error-key))
234 (n-wrong-key (string-length wrong-key))
235 (name-width 20)
236 (timing-width 10))
237 (let loop ((lines lines))
238 (if (null? lines)
239 (newline out)
240 (let ((line (car lines)))
241 (cond ((substring=? system-key line 0 n-system-key)
242 (display line out)
243 (newline out)
244 (newline out)
245 (display
246 "benchmark cpu real gc"
247 out)
248 (newline out))
249 ((substring=? test-key line 0 n-test-key)
250 (newline out)
251 (let ((name (substring line
252 n-test-key
253 (substring? test-key-tail line))))
254 (left-justify name name-width out)))
255 ((and (substring=? cpu-key line 0 n-cpu-key)
256 (substring? real-key line))
257 (let* ((n1 (substring? real-key line))
258 (s (substring line n-cpu-key n1))
259 (s1 (list->string
260 (filter (lambda (c) (not (char=? c #\space)))
261 (string->list s))))
262 (x (string->number s1))
263 (s (substring line
264 (+ n1 n-real-key)
265 (string-length line)))
266 (s2 (list->string
267 (filter (lambda (c) (not (char=? c #\space)))
268 (string->list s))))
269 (y (string->number s2)))
270 (right-justify x timing-width out)
271 (right-justify y timing-width out)))
272 (#f ;(substring? gc-key line)
273 (let* ((n1 (substring? gc-key line))
274 (s (substring line 0 n1))
275 (s1 (list->string
276 (filter (lambda (c) (not (char=? c #\space)))
277 (string->list s))))
278 (x (string->msec s1)))
279 (right-justify x timing-width out)
280 (newline out)))
281 ((substring=? error-key line 0 n-error-key)
282 (display line out)
283 (newline out)
284 (display (make-string name-width #\space) out))
285 ((substring=? wrong-key line 0 n-wrong-key)
286 (display line out)
287 (newline out)
288 (display (make-string name-width #\space) out)))
289 (loop (cdr lines))))))))
290
291 ; Scheme 48
292
293 (define (scheme48-results lines out)
294 (generic-results "Scheme48" lines out))
295
296 ; Gambit-C
297
298 (define (gambit-results lines out)
299 (let ((system-key "Benchmarking ")
300 (test-key "Testing ")
301 (test-key-tail " under Gambit-C")
302 (cpu-key " ms cpu time")
303 (real-key " ms real time")
304 (gc-key " collections accounting for ")
305 (ms-key " ms")
306 (space-key " ")
307 (error-key "Error: ")
308 (wrong-key "*** wrong result ***"))
309 (let ((n-system-key (string-length system-key))
310 (n-test-key (string-length test-key))
311 (n-cpu-key (string-length cpu-key))
312 (n-real-key (string-length real-key))
313 (n-gc-key (string-length gc-key))
314 (n-ms-key (string-length ms-key))
315 (n-space-key (string-length space-key))
316 (n-error-key (string-length error-key))
317 (n-wrong-key (string-length wrong-key))
318 (name-width 20)
319 (timing-width 10))
320 (let loop ((lines lines)
321 (real ""))
322 (if (null? lines)
323 (newline out)
324 (let ((line (car lines)))
325 (cond ((substring=? system-key line 0 n-system-key)
326 (display line out)
327 (newline out)
328 (newline out)
329 (display "benchmark cpu real gc"
330 out)
331 (newline out))
332 ((substring=? test-key line 0 n-test-key)
333 (newline out)
334 (let ((name (substring line
335 n-test-key
336 (substring? test-key-tail line))))
337 (left-justify name name-width out)))
338 ((substring? gc-key line)
339 (let ((x (substring line
340 (+ n-gc-key (substring? gc-key line))
341 (substring? ms-key line))))
342 (right-justify x timing-width out)
343 (newline out)))
344 ((substring? cpu-key line)
345 (let ((x (substring line
346 n-space-key
347 (substring? cpu-key line))))
348 (right-justify x timing-width out)
349 (right-justify real timing-width out)))
350 ((substring? real-key line)
351 (let ((x (substring line
352 n-space-key
353 (substring? real-key line))))
354 (set! real x)))
355 ((substring=? error-key line 0 n-error-key)
356 (display line out)
357 (newline out)
358 (display (make-string name-width #\space) out))
359 ((substring=? wrong-key line 0 n-wrong-key)
360 (display " " out)
361 (display line out)
362 (newline out)
363 (display (make-string name-width #\space) out)))
364 (loop (cdr lines) real)))))))
365
366 ; Chez and Ikarus Scheme.
367
368 (define (chez-results lines out)
369 (chez-results-proto "Chez-Scheme" lines out))
370
371 (define (petite-chez-results lines out)
372 (chez-results-proto "Petite-Chez-Scheme" lines out))
373
374 (define (ikarus-results lines out)
375 (chez-results-proto "Ikarus" lines out))
376
377 (define (chez-results-proto sysname lines out)
378 (let ((system-key "Benchmarking ")
379 (test-key "Testing ")
380 (test-key-tail (string-append " under " sysname))
381 (cpu-key " ms elapsed cpu time")
382 (real-key " ms elapsed real time")
383 (space-key " ")
384 (error-key "Error")
385 (wrong-key "*** wrong result ***"))
386 (let ((n-system-key (string-length system-key))
387 (n-test-key (string-length test-key))
388 (n-cpu-key (string-length cpu-key))
389 (n-real-key (string-length real-key))
390 (n-space-key (string-length space-key))
391 (n-error-key (string-length error-key))
392 (n-wrong-key (string-length wrong-key))
393 (name-width 20)
394 (timing-width 10))
395 (let loop ((lines lines))
396 (if (null? lines)
397 (newline out)
398 (let ((line (car lines)))
399 (cond ((substring=? system-key line 0 n-system-key)
400 (display line out)
401 (newline out)
402 (newline out)
403 (display "benchmark cpu real" out)
404 (newline out))
405 ((substring=? test-key line 0 n-test-key)
406 (newline out)
407 (let ((name (substring line
408 n-test-key
409 (substring? test-key-tail line))))
410 (left-justify name name-width out)))
411 ((substring? cpu-key line)
412 (let ((x (substring line
413 n-space-key
414 (substring? cpu-key line))))
415 (right-justify x timing-width out)))
416 ((substring? real-key line)
417 (let ((x (substring line
418 n-space-key
419 (substring? real-key line))))
420 (right-justify x timing-width out)))
421 ((substring=? error-key line 0 n-error-key)
422 (display line out)
423 ;(newline out)
424 ;(display (make-string name-width #\space) out)
425 )
426 ((substring=? wrong-key line 0 n-wrong-key)
427 (display " " out)
428 (display line out)
429 (newline out)
430 (display (make-string name-width #\space) out)))
431 ;(flush-output-port out)
432 (loop (cdr lines))))))))
433
434 ; Larceny
435
436 (define (larceny-results lines out)
437 (larceny-results-proto "Larceny" lines out))
438
439 (define (henchman-results lines out)
440 (larceny-results-proto "Henchman" lines out))
441
442 (define (larceny-results-proto sysname lines out)
443 (let ((system-key "Benchmarking ")
444 (test-key "Testing ")
445 (test-key-tail (string-append " under " sysname))
446 (cpu-key "User: ")
447 (real-key "Elapsed time...: ")
448 (gc-key "Elapsed GC time: ")
449 (ms-key " ms")
450 (error-key "Error: ")
451 (wrong-key "*** wrong result ***"))
452 (let ((n-system-key (string-length system-key))
453 (n-test-key (string-length test-key))
454 (n-cpu-key (string-length cpu-key))
455 (n-real-key (string-length real-key))
456 (n-gc-key (string-length gc-key))
457 (n-ms-key (string-length ms-key))
458 (n-error-key (string-length error-key))
459 (n-wrong-key (string-length wrong-key))
460 (name-width 20)
461 (timing-width 10))
462 (let loop ((lines lines))
463 (if (null? lines)
464 (newline out)
465 (let ((line (car lines)))
466 (cond ((substring=? system-key line 0 n-system-key)
467 (display line out)
468 (newline out)
469 (newline out)
470 (display
471 "benchmark cpu real gc"
472 out)
473 (newline out))
474 ((substring=? test-key line 0 n-test-key)
475 (newline out)
476 (let ((name (substring line
477 n-test-key
478 (substring? test-key-tail line))))
479 (left-justify name name-width out)))
480 ((substring=? real-key line 0 n-real-key)
481 (let* ((n1 (substring? ms-key line))
482 (n2 (substring? cpu-key line))
483 (s (substring line n2 (string-length line)))
484 (n3 (substring? ms-key s))
485 (x (substring line n-real-key n1))
486 (y (substring s n-cpu-key n3)))
487 (right-justify y timing-width out)
488 (right-justify x timing-width out)))
489 ((substring=? gc-key line 0 n-gc-key)
490 (let* ((n1 (substring? ms-key line))
491 (x (substring line n-gc-key n1)))
492 (right-justify x timing-width out)))
493 ((substring=? error-key line 0 n-error-key)
494 (display line out)
495 (newline out)
496 (display (make-string name-width #\space) out))
497 ((substring=? wrong-key line 0 n-wrong-key)
498 (display line out)
499 (newline out)
500 (display (make-string name-width #\space) out)))
501 (loop (cdr lines))))))))
502
503 ; Chicken
504
505 (define (chicken-results lines out)
506 (generic-results "Chicken" lines out))
507
508 ; MzScheme
509
510 (define (mzscheme-results lines out)
511 (let ((system-key "Benchmarking ")
512 (test-key "Testing ")
513 (test-key-tail " under MzScheme")
514 (cpu-key "cpu time: ")
515 (real-key "real time: ")
516 (gc-key "gc time: ")
517 (ms-key " ms")
518 (error-key "Error: ")
519 (wrong-key "*** wrong result ***"))
520 (let ((n-system-key (string-length system-key))
521 (n-test-key (string-length test-key))
522 (n-cpu-key (string-length cpu-key))
523 (n-real-key (string-length real-key))
524 (n-gc-key (string-length gc-key))
525 (n-ms-key (string-length ms-key))
526 (n-error-key (string-length error-key))
527 (n-wrong-key (string-length wrong-key))
528 (name-width 20)
529 (timing-width 10))
530 (let loop ((lines lines))
531 (if (null? lines)
532 (newline out)
533 (let ((line (car lines)))
534 (cond ((substring=? system-key line 0 n-system-key)
535 (display line out)
536 (newline out)
537 (newline out)
538 (display
539 "benchmark cpu real gc"
540 out)
541 (newline out))
542 ((substring=? test-key line 0 n-test-key)
543 (newline out)
544 (let ((name (substring line
545 n-test-key
546 (substring? test-key-tail line))))
547 (left-justify name name-width out)))
548 ((substring=? cpu-key line 0 n-cpu-key)
549 (let* ((n1 (substring? real-key line))
550 (n2 (substring? gc-key line))
551 (s (substring line n2 (string-length line)))
552 (x (substring line n-cpu-key (- n1 1)))
553 (y (substring line
554 (+ n1 n-real-key)
555 (- n2 1)))
556 (z (substring line
557 (+ n2 n-gc-key)
558 (string-length line))))
559 (right-justify x timing-width out)
560 (right-justify y timing-width out)
561 (right-justify z timing-width out)
562 (newline out)))
563 ((substring=? error-key line 0 n-error-key)
564 (display line out)
565 (newline out)
566 (display (make-string name-width #\space) out))
567 ((substring=? wrong-key line 0 n-wrong-key)
568 (display line out)
569 (newline out)
570 (display (make-string name-width #\space) out)))
571 (loop (cdr lines))))))))
572
573 ; Bigloo
574
575 (define (bigloo-results lines out)
576 (generic-results "Bigloo" lines out))
577
578 ; The following is commented out.
579
580 '
581 (define (bigloo-results lines out)
582 (let ((system-key "Benchmarking ")
583 (test-key "Testing ")
584 (test-key-tail " under Bigloo")
585 (run-key "Running...")
586 (cpu-key "user")
587 (real-key "real")
588 (error-key "Error: ")
589 (wrong-key "*** wrong result ***"))
590 (let ((n-system-key (string-length system-key))
591 (n-test-key (string-length test-key))
592 (n-run-key (string-length run-key))
593 (n-cpu-key (string-length cpu-key))
594 (n-real-key (string-length real-key))
595 (n-error-key (string-length error-key))
596 (n-wrong-key (string-length wrong-key))
597 (name-width 20)
598 (timing-width 10))
599 (let loop ((lines lines))
600 (if (null? lines)
601 (newline out)
602 (let ((line (car lines)))
603 (cond ((substring=? system-key line 0 n-system-key)
604 (display line out)
605 (newline out)
606 (newline out)
607 (display
608 "benchmark cpu real gc"
609 out)
610 (newline out))
611 ((substring=? test-key line 0 n-test-key)
612 (newline out)
613 (let ((name (substring line
614 n-test-key
615 (substring? test-key-tail line))))
616 (left-justify name name-width out)))
617 ((substring=? run-key line 0 n-run-key)
618 (let* ((lines
619 (do ((lines (cdr lines) (cdr lines)))
620 ((substring=? real-key
621 (car lines) 0 n-real-key)
622 lines)))
623 (line1 (car lines))
624 (line2 (cadr lines))
625 (y (string->msec
626 (substring line1
627 n-real-key
628 (string-length line1))))
629 (x (string->msec
630 (substring line2
631 n-cpu-key
632 (string-length line2)))))
633 (right-justify x timing-width out)
634 (right-justify y timing-width out)
635 (newline out)))
636 ((substring=? error-key line 0 n-error-key)
637 (display line out)
638 (newline out)
639 (display (make-string name-width #\space) out))
640 ((substring=? wrong-key line 0 n-wrong-key)
641 (display line out)
642 (newline out)
643 (display (make-string name-width #\space) out)))
644 (loop (cdr lines))))))))
645
646 ; MIT Scheme
647
648 (define (mit-results lines out)
649 (generic-results "MIT-Scheme" lines out))
650
651 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
652 ;
653 ; Conversion of the summaries into Scheme-readable data.
654 ;
655 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
656
657 ; Given a file name or input port containing a summary
658 ; produced by the summarize procedure above,
659 ; returns a decoded summary of the form
660 ;
661 ; (<system> ; a string, e.g. "Larceny"
662 ; (<hostname> <date> ...) ; strings
663 ; ((<benchmark> ; a symbol, e.g. fib
664 ; <cputime> ; a number, in milliseconds
665 ; <realtime> ; a number, in milliseconds
666 ; <gctime>) ; a number, in milliseconds
667 ; ...))
668
669 (define make-summary list)
670 (define make-timing list)
671
672 (define summary:system car)
673 (define summary:hostetc cadr)
674 (define summary:timings caddr)
675 (define timing:benchmark car)
676 (define timing:cpu cadr)
677 (define timing:real caddr)
678 (define timing:gc cadddr)
679
680 (define (decode-summary in)
681 (define (bad-arguments)
682 (error "Bad arguments to summarize-results" in))
683 (cond ((string? in)
684 (call-with-input-file
685 in
686 (lambda (in) (decode-summary in))))
687 ((input-port? in)
688 (decode-lines (readlines in)))
689 (else
690 (bad-arguments))))
691
692 ; Given the summary as a list of lines,
693 ; returns the decoded summary as for decode-summary.
694
695 (define (decode-lines lines)
696 (let ((system-key "Benchmarking ")
697 (date-key " on ")
698 (header-key "benchmark"))
699 (let ((n-system-key (string-length system-key))
700 (n-date-key (string-length date-key))
701 (n-header-key (string-length header-key)))
702 (and (not (null? lines))
703 (substring=? system-key (car lines) 0 n-system-key))
704 (let* ((line0 (car lines))
705 (n0 (string-length line0))
706 (n1 (substring? date-key line0))
707 (system (substring line0 n-system-key n1))
708 (hostname "unknown")
709 (date (substring line0 (+ n1 n-date-key) n0))
710 (benchmarks
711 (map (lambda (line)
712 (let* ((padding " #f #f #f #f")
713 (in (open-input-string
714 (string-append line padding)))
715 (name (read in)))
716 (let loop ((tot-cpu 0)
717 (tot-real 0)
718 (tot-gc 0)
719 (count 0))
720 (let* ((cpu (read in))
721 (real (read in))
722 (gc (read in)))
723 (cond ((or (not (number? cpu))
724 (not (number? real))
725 (not (number? gc)))
726 (cond ((= count 0)
727 (list name cpu real gc))
728 (else
729 (list name
730 (quotient tot-cpu count)
731 (quotient tot-real count)
732 (quotient tot-gc count)))))
733 (else
734 (loop (+ tot-cpu cpu)
735 (+ tot-real real)
736 (+ tot-gc gc)
737 (+ count 1))))))))
738 (cdr lines)))
739 (benchmarks
740 (filter (lambda (x)
741 (and (car x)
742 (symbol? (car x))
743 (not (eq? (car x) 'benchmark))
744 (number? (cadr x))
745 (number? (caddr x))
746 (positive? (caddr x))))
747 benchmarks)))
748 (list system
749 (list hostname date)
750 benchmarks)))))