Debian Codegraph @

benchmarks.larceny/generate-html-from-all-results.scm

raw symbols SCIP
1 (load "all-results.scm")
2
3 (define systems
4 (map car all-results))
5
6 (define benchmarks
7 (map car (cdr (car all-results))))
8
9 (define non-schemes '(GCC))
10
11 (define (iota n)
12 (let loop ((i 0))
13 (if (< i n)
14 (cons i (loop (+ i 1)))
15 '())))
16
17 (define (keep keep? lst)
18 (cond ((null? lst) '())
19 ((keep? (car lst)) (cons (car lst) (keep keep? (cdr lst))))
20 (else (keep keep? (cdr lst)))))
21
22 (define (every? pred? lst)
23 (or (null? lst)
24 (and (pred? (car lst))
25 (every? pred? (cdr lst)))))
26
27 (define (p arg)
28 (cond ((null? arg))
29 ((pair? arg)
30 (p (car arg))
31 (p (cdr arg)))
32 (else
33 (display arg))))
34
35 (define (format-real x decimals)
36 (let* ((divisor (expt 10 decimals))
37 (n (inexact->exact (round (* 100. x)))))
38 (string-append (number->string (quotient n divisor))
39 "."
40 (substring (number->string
41 (+ divisor (modulo n divisor)))
42 1
43 (+ decimals 1)))))
44
45 (define (wrap before after)
46 (lambda (args)
47 (list before args after)))
48
49 (define table (wrap "<table>\n" "</table>\n"))
50 (define tr-head (wrap "<tr>\n" "</tr>\n"))
51 (define tr-odd (wrap "<tr bgcolor=\"#eeeeee\">\n" "</tr>\n"))
52 (define tr-even (wrap "<tr bgcolor=\"#dddddd\">\n" "</tr>\n"))
53 (define td (wrap "<td>\n" "</td>\n"))
54 (define td-left (wrap "<td align=\"left\">\n" "</td>\n"))
55 (define td-center (wrap "<td align=\"center\">\n" "</td>\n"))
56 (define td-right (wrap "<td align=\"right\">\n" "</td>\n"))
57 (define td-best (wrap "<td align=\"center\" bgcolor=\"#80f080\">\n" "</td>\n"))
58 (define td-head (wrap "<td colspan=\"1\" align=\"center\">\n" "</td>\n"))
59 (define code (wrap "<code>\n" "</code>\n"))
60 (define b (wrap "<b>\n" "</b>\n"))
61 (define i (wrap "<i>\n" "</i>\n"))
62 (define line (wrap "" "\n"))
63
64 (define (extract-times bench cpu? results)
65 (map (lambda (sys)
66 (let ((r (assq bench (cdr sys))))
67 (cond ((>= (length r) 3)
68 (if cpu? (cadr r) (caddr r)))
69 ((= (length r) 2)
70 (cadr r))
71 (else
72 '()))))
73 results))
74
75 (define (gen cpu?)
76 (table
77 (map (lambda (j x)
78 ((cond ((= j 0) tr-head)
79 ((odd? j) tr-odd)
80 (else tr-even))
81 x))
82 (iota (+ 1 (length benchmarks)))
83 (cons (map td-head (cons "Program&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" systems))
84 (map (lambda (bench)
85 (let* ((scheme-times
86 (extract-times
87 bench
88 cpu?
89 (keep (lambda (x) (not (memq (car x) non-schemes)))
90 all-results)))
91 (times
92 (extract-times bench cpu? all-results))
93 (num-times
94 (keep number? scheme-times))
95 (best-time
96 (if (null? num-times) 0 (apply min num-times))))
97 (cons (td (line (code bench)))
98 (map (lambda (sys t)
99 (cond ((number? t)
100 (if (and (= t best-time)
101 (not (memq (car sys)
102 non-schemes)))
103 (td-best (line (i t)))
104 (td-right (line (if (= best-time 0)
105 "inf"
106 (format-real (/ t best-time) 2))))))
107 ((null? t)
108 (td-center (line "")))
109 (else
110 (td-center (line t)))))
111 all-results
112 times))))
113 benchmarks)))))
114
115 (define (generate-table)
116 (p
117 (list
118 "The following tables contain the execution time of the Gambit benchmarks"
119 " on various implementations of Scheme. For a given benchmark, the"
120 " entry in green indicates which Scheme system has the fastest execution"
121 " and the number given is the time in milliseconds. Other entries"
122 " give the execution time relative to the green entry. Blank entries"
123 " indicate that this benchmark was not executed (possibly because the"
124 " system did not accept to compile the program)."
125 "<br>"
126 "<br>"
127 "The first table gives CPU time and the second gives real time."
128 "<h1>CPU time</h1>"
129 (gen #t)
130 "<h1>Real time</h1>"
131 (gen #f))))
132
133 (with-output-to-file
134 "bench.html"
135 generate-table)