generate-html-from-all-results.scm 4.9 KB

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