Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial revision

  • Loading branch information...
commit 26872eba22e77d5d875d77407e96fb09b8e76f83 0 parents
bfulgham authored
Showing with 10,981 additions and 0 deletions.
  1. 0  .craps.table
  2. +157 −0 ChangeLog
  3. +47 −0 Make.footer
  4. +51 −0 Make.header
  5. +34 −0 Makefile
  6. +29 −0 Minibench.conf
  7. +18 −0 Notes.txt
  8. +3 −0  README
  9. +7 −0 Todo
  10. +174 −0 ack.shtml
  11. +83 −0 bench/Include/doubly_linked_list.e
  12. +62 −0 bench/Include/hash_item.e
  13. +340 −0 bench/Include/hash_map.e
  14. +197 −0 bench/Include/meta.lisp
  15. +39 −0 bench/Include/nth_toggle.e
  16. +33 −0 bench/Include/randomnumber.e
  17. +33 −0 bench/Include/randomnumber.e_no_max
  18. +183 −0 bench/Include/simple_hash.h
  19. +204 −0 bench/Include/simple_hash2.h
  20. +32 −0 bench/Include/toggle.e
  21. +43 −0 bench/Makefile
  22. +225 −0 bench/Makefile.mb
  23. +1 −0  bench/ackermann/.up_date
  24. +12 −0 bench/ackermann/Makefile
  25. +1 −0  bench/ackermann/Output
  26. +20 −0 bench/ackermann/ackermann.bash
  27. +18 −0 bench/ackermann/ackermann.bigloo
  28. +22 −0 bench/ackermann/ackermann.cmucl
  29. +16 −0 bench/ackermann/ackermann.erlang
  30. +17 −0 bench/ackermann/ackermann.g++
  31. +14 −0 bench/ackermann/ackermann.gawk
  32. +20 −0 bench/ackermann/ackermann.gcc
  33. +15 −0 bench/ackermann/ackermann.ghc
  34. +18 −0 bench/ackermann/ackermann.guile
  35. +15 −0 bench/ackermann/ackermann.lua
  36. +14 −0 bench/ackermann/ackermann.mawk
  37. +25 −0 bench/ackermann/ackermann.mlton
  38. +15 −0 bench/ackermann/ackermann.mzscheme
  39. +13 −0 bench/ackermann/ackermann.ocaml
  40. +13 −0 bench/ackermann/ackermann.ocamlb
  41. +27 −0 bench/ackermann/ackermann.perl
  42. +15 −0 bench/ackermann/ackermann.pike
  43. +20 −0 bench/ackermann/ackermann.python
  44. +17 −0 bench/ackermann/ackermann.ruby
  45. +40 −0 bench/ackermann/ackermann.se
  46. +29 −0 bench/ackermann/ackermann.smlnj
  47. +21 −0 bench/ackermann/ackermann.tcl
  48. +16 −0 bench/ackermann/ackermann.xemacs
  49. +22 −0 bench/ackermann/alt/HEADER.html
  50. +17 −0 bench/ackermann/alt/README.html
  51. +98 −0 bench/ackermann/alt/ackermann.gas
  52. +17 −0 bench/ackermann/alt/ackermann.ocaml2.ocaml
  53. +24 −0 bench/ackermann/alt/ackermann.perl2.perl
  54. +26 −0 bench/ackermann/alt/ackermann.pike2.pike
  55. +15 −0 bench/ackermann/alt/ackermann.pike3.pike
  56. +50 −0 bench/ackermann/alt/ackermann.se2.se
  57. +34 −0 bench/ackermann/alt/ackermann.tcl2.tcl
  58. +79 −0 bench/ackermann/alt/ann.ackermann.forth
  59. +15 −0 bench/ackermann/detail.shtml
  60. +147 −0 bench/ackermann/index.shtml
  61. +1 −0  bench/ary/.up_date
  62. +13 −0 bench/ary/Makefile
  63. +1 −0  bench/ary/Output
  64. +1 −0  bench/ary/THIS_TEST_HAS_BEEN_OBSOLETED
  65. +22 −0 bench/ary/alt/HEADER.html
  66. +17 −0 bench/ary/alt/README.html
  67. +20 −0 bench/ary/alt/ary.ghc2.ghc
  68. +24 −0 bench/ary/alt/ary.ghc3.ghc
  69. +28 −0 bench/ary/ary.bigloo
  70. +21 −0 bench/ary/ary.cmucl
  71. +23 −0 bench/ary/ary.g++
  72. +19 −0 bench/ary/ary.gawk
  73. +36 −0 bench/ary/ary.gcc
  74. +26 −0 bench/ary/ary.ghc
  75. +20 −0 bench/ary/ary.guile
  76. +16 −0 bench/ary/ary.lua
  77. +19 −0 bench/ary/ary.mawk
  78. +37 −0 bench/ary/ary.mlton
  79. +20 −0 bench/ary/ary.ocaml
  80. +20 −0 bench/ary/ary.ocamlb
  81. +23 −0 bench/ary/ary.perl
  82. +22 −0 bench/ary/ary.pike
  83. +18 −0 bench/ary/ary.python
  84. +17 −0 bench/ary/ary.python2.python
  85. +21 −0 bench/ary/ary.ruby
  86. +59 −0 bench/ary/ary.se
  87. +37 −0 bench/ary/ary.smlnj
  88. +25 −0 bench/ary/ary.tcl
  89. +16 −0 bench/ary/ary.xemacs
  90. +14 −0 bench/ary/detail.shtml
  91. +87 −0 bench/ary/index.shtml
  92. +4 −0 bench/done.txt
  93. +1 −0  bench/echo/.up_date
  94. +17 −0 bench/echo/Makefile
  95. +1 −0  bench/echo/Output
  96. +22 −0 bench/echo/alt/HEADER.html
  97. +17 −0 bench/echo/alt/README.html
  98. 0  bench/echo/alt/echo.perl2.perl
  99. 0  bench/echo/alt/echo.pike2.pike
  100. +14 −0 bench/echo/detail.shtml
  101. +50 −0 bench/echo/echo.bigloo
  102. +68 −0 bench/echo/echo.cmucl
  103. +55 −0 bench/echo/echo.erlang
  104. +152 −0 bench/echo/echo.g++
  105. +144 −0 bench/echo/echo.gcc
  106. +81 −0 bench/echo/echo.ghc
  107. +43 −0 bench/echo/echo.guile
  108. +59 −0 bench/echo/echo.mlton
  109. +42 −0 bench/echo/echo.mzscheme
  110. +66 −0 bench/echo/echo.ocaml
  111. +66 −0 bench/echo/echo.ocamlb
  112. +81 −0 bench/echo/echo.perl
  113. +60 −0 bench/echo/echo.pike
  114. +64 −0 bench/echo/echo.python
  115. +41 −0 bench/echo/echo.ruby
  116. +82 −0 bench/echo/echo.smlnj
  117. +45 −0 bench/echo/echo.tcl
  118. +92 −0 bench/echo/index.shtml
  119. +68 −0 bench/echo/new/echo.cmucl
  120. +55 −0 bench/echo/new/echo.erlang
  121. 0  bench/echo/new/echo.python
  122. +82 −0 bench/echo/new/echo.smlnj
  123. +8 −0 bench/echo/tclwrapper
  124. +1 −0  bench/except/.up_date
  125. +13 −0 bench/except/Makefile
  126. +1 −0  bench/except/Output
  127. +22 −0 bench/except/alt/HEADER.html
  128. +17 −0 bench/except/alt/README.html
  129. +41 −0 bench/except/alt/except.cmucl2.cmucl
  130. 0  bench/except/alt/except.python2.python
  131. +14 −0 bench/except/detail.shtml
  132. +49 −0 bench/except/except.bigloo
  133. +33 −0 bench/except/except.cmucl
  134. +69 −0 bench/except/except.g++
  135. +52 −0 bench/except/except.gcc
  136. +38 −0 bench/except/except.ghc
  137. +39 −0 bench/except/except.guile
  138. +51 −0 bench/except/except.lua
  139. +58 −0 bench/except/except.mlton
  140. +37 −0 bench/except/except.mzscheme
  141. +27 −0 bench/except/except.ocaml
  142. +27 −0 bench/except/except.ocamlb
  143. +73 −0 bench/except/except.perl
  144. +55 −0 bench/except/except.pike
  145. +62 −0 bench/except/except.python
  146. +61 −0 bench/except/except.ruby
  147. +61 −0 bench/except/except.ruby2.ruby
  148. +109 −0 bench/except/except.se
  149. +63 −0 bench/except/except.smlnj
  150. +59 −0 bench/except/except.tcl
  151. +41 −0 bench/except/except.xemacs
  152. +93 −0 bench/except/index.shtml
  153. +1 −0  bench/fibo/.up_date
  154. +16 −0 bench/fibo/Makefile
  155. +1 −0  bench/fibo/Output
  156. +22 −0 bench/fibo/alt/HEADER.html
  157. +17 −0 bench/fibo/alt/README.html
  158. +31 −0 bench/fibo/alt/fibo.foley.cmucl
  159. +41 −0 bench/fibo/alt/fibo.ocaml2.ocaml
  160. +17 −0 bench/fibo/alt/fibo.ocaml3.ocaml
  161. 0  bench/fibo/alt/fibo.perl2.perl
  162. 0  bench/fibo/alt/fibo.perl3.perl
  163. 0  bench/fibo/alt/fibo.python2.python
  164. 0  bench/fibo/alt/fibo.python3.python
  165. 0  bench/fibo/alt/fibo.tcl2.tcl
  166. +14 −0 bench/fibo/detail.shtml
  167. +14 −0 bench/fibo/fibo.bash
  168. +17 −0 bench/fibo/fibo.bigloo
  169. +15 −0 bench/fibo/fibo.cmucl
  170. +16 −0 bench/fibo/fibo.cmucl2.cmucl
  171. +15 −0 bench/fibo/fibo.erlang
  172. +22 −0 bench/fibo/fibo.g++
  173. +13 −0 bench/fibo/fibo.gawk
  174. +19 −0 bench/fibo/fibo.gcc
  175. +19 −0 bench/fibo/fibo.ghc
  176. +15 −0 bench/fibo/fibo.guile
  177. +10 −0 bench/fibo/fibo.lua
  178. +13 −0 bench/fibo/fibo.mawk
  179. +24 −0 bench/fibo/fibo.mlton
  180. +15 −0 bench/fibo/fibo.mzscheme
  181. +8 −0 bench/fibo/fibo.ocaml
  182. +8 −0 bench/fibo/fibo.ocamlb
  183. +15 −0 bench/fibo/fibo.perl
  184. +17 −0 bench/fibo/fibo.pike
  185. +17 −0 bench/fibo/fibo.python
  186. +15 −0 bench/fibo/fibo.ruby
  187. +35 −0 bench/fibo/fibo.se
  188. +28 −0 bench/fibo/fibo.smlnj
  189. +17 −0 bench/fibo/fibo.tcl
  190. +15 −0 bench/fibo/fibo.xemacs
  191. +106 −0 bench/fibo/index.shtml
  192. +13 −0 bench/gifdeanim/Makefile
  193. +1 −0  bench/gifdeanim/Output
  194. +22 −0 bench/gifdeanim/alt/HEADER.html
  195. +17 −0 bench/gifdeanim/alt/README.html
  196. +14 −0 bench/gifdeanim/detail.shtml
  197. 0  bench/gifdeanim/gifdeanim.perl
  198. +35 −0 bench/gifdeanim/index.shtml
  199. +1 −0  bench/hash/.up_date
  200. +21 −0 bench/hash/Makefile
  201. +1 −0  bench/hash/Output
  202. +22 −0 bench/hash/alt/HEADER.html
  203. +17 −0 bench/hash/alt/README.html
  204. 0  bench/hash/alt/hash.python2.python
  205. +76 −0 bench/hash/alt/hash.se2.se
  206. +14 −0 bench/hash/detail.shtml
  207. +27 −0 bench/hash/hash.bigloo
  208. +31 −0 bench/hash/hash.cmucl
  209. +46 −0 bench/hash/hash.erlang
  210. +36 −0 bench/hash/hash.g++
  211. +19 −0 bench/hash/hash.gawk
  212. +31 −0 bench/hash/hash.gcc
  213. +27 −0 bench/hash/hash.ghc
  214. +29 −0 bench/hash/hash.ghc2.ghc
  215. +21 −0 bench/hash/hash.guile
  216. +18 −0 bench/hash/hash.lua
  217. +19 −0 bench/hash/hash.mawk
  218. +41 −0 bench/hash/hash.mlton
  219. +24 −0 bench/hash/hash.mzscheme
  220. +23 −0 bench/hash/hash.ocaml
  221. +23 −0 bench/hash/hash.ocamlb
  222. +23 −0 bench/hash/hash.perl
  223. +17 −0 bench/hash/hash.perl2.perl
  224. +24 −0 bench/hash/hash.perl3.perl
  225. +22 −0 bench/hash/hash.pike
  226. +21 −0 bench/hash/hash.python
  227. +19 −0 bench/hash/hash.ruby
  228. +51 −0 bench/hash/hash.se
  229. +44 −0 bench/hash/hash.smlnj
  230. +26 −0 bench/hash/hash.tcl
  231. +18 −0 bench/hash/hash.xemacs
  232. +100 −0 bench/hash/index.shtml
  233. +1 −0  bench/hash2/.up_date
  234. +19 −0 bench/hash2/Makefile
  235. +1 −0  bench/hash2/Output
  236. +22 −0 bench/hash2/alt/HEADER.html
  237. +17 −0 bench/hash2/alt/README.html
  238. +88 −0 bench/hash2/alt/hash2.g++2.g++
  239. 0  bench/hash2/alt/hash2.tcl2.tcl
  240. +15 −0 bench/hash2/detail.shtml
  241. +31 −0 bench/hash2/hash2.bash
  242. +41 −0 bench/hash2/hash2.bigloo
  243. +37 −0 bench/hash2/hash2.cmucl
  244. +48 −0 bench/hash2/hash2.erlang
  245. +35 −0 bench/hash2/hash2.g++
  246. +13 −0 bench/hash2/hash2.gawk
  247. +38 −0 bench/hash2/hash2.gcc
  248. +27 −0 bench/hash2/hash2.guile
  249. +19 −0 bench/hash2/hash2.lua
  250. +13 −0 bench/hash2/hash2.mawk
  251. +50 −0 bench/hash2/hash2.mlton
  252. +27 −0 bench/hash2/hash2.mzscheme
  253. +16 −0 bench/hash2/hash2.ocaml
  254. +16 −0 bench/hash2/hash2.ocamlb
  255. +16 −0 bench/hash2/hash2.perl
  256. +18 −0 bench/hash2/hash2.perl2.perl
  257. +21 −0 bench/hash2/hash2.pike
  258. +22 −0 bench/hash2/hash2.python
  259. +20 −0 bench/hash2/hash2.python2.python
  260. +21 −0 bench/hash2/hash2.ruby
  261. +59 −0 bench/hash2/hash2.se
  262. +54 −0 bench/hash2/hash2.smlnj
  263. +22 −0 bench/hash2/hash2.tcl
  264. +23 −0 bench/hash2/hash2.xemacs
  265. +84 −0 bench/hash2/index.shtml
  266. +1 −0  bench/heapsort/.up_date
  267. +18 −0 bench/heapsort/Makefile
  268. +1 −0  bench/heapsort/Output
  269. +187 −0 bench/heapsort/about.shtml
  270. +22 −0 bench/heapsort/alt/HEADER.html
  271. +17 −0 bench/heapsort/alt/README.html
  272. 0  bench/heapsort/alt/heapsort.perl2.perl
  273. +15 −0 bench/heapsort/detail.shtml
  274. +59 −0 bench/heapsort/heapsort.bigloo
  275. +62 −0 bench/heapsort/heapsort.cmucl
  276. +72 −0 bench/heapsort/heapsort.g++
  277. +52 −0 bench/heapsort/heapsort.gawk
  278. +72 −0 bench/heapsort/heapsort.gcc
  279. +54 −0 bench/heapsort/heapsort.ghc
  280. +61 −0 bench/heapsort/heapsort.guile
  281. +59 −0 bench/heapsort/heapsort.lua
  282. +52 −0 bench/heapsort/heapsort.mawk
  283. +74 −0 bench/heapsort/heapsort.mlton
  284. +64 −0 bench/heapsort/heapsort.mzscheme
  285. +51 −0 bench/heapsort/heapsort.ocaml
  286. +51 −0 bench/heapsort/heapsort.ocamlb
  287. +65 −0 bench/heapsort/heapsort.perl
  288. +62 −0 bench/heapsort/heapsort.pike
  289. +59 −0 bench/heapsort/heapsort.python
  290. +54 −0 bench/heapsort/heapsort.ruby
  291. +53 −0 bench/heapsort/heapsort.scheme
  292. +92 −0 bench/heapsort/heapsort.se
  293. +81 −0 bench/heapsort/heapsort.smlnj
  294. +73 −0 bench/heapsort/heapsort.tcl
  295. +51 −0 bench/heapsort/heapsort.xemacs
  296. +80 −0 bench/heapsort/index.shtml
  297. +1 −0  bench/hello/.up_date
  298. +24 −0 bench/hello/Makefile
  299. +44 −0 bench/hello/Minibench.conf
  300. +1 −0  bench/hello/Output
Sorry, we could not display the entire diff because too many files (973) changed.
0  .craps.table
No changes.
157 ChangeLog
@@ -0,0 +1,157 @@
+2000-12-03 (Doug Bagley)
+
+ * Switched from ChangeLog to automated Activity Log.
+
+ * Added some Pike programs from Fredrik Noring, et. al.
+
+2000-11-27 (Doug Bagley)
+
+ * Released version 0.1.7.
+
+2000-11-26 (Doug Bagley)
+
+ * Totally re-wrote the benchtest script, it is now called
+ minibench, and it has lots of nice features. It should start
+ getting easier for others to use it as a benchmarking tool. New
+ option --repeat should allow us to get a better idea of
+ variability in cputime from run to run.
+
+2000-11-23 (Doug Bagley)
+
+ * Released version 0.1.6 with latest fixes.
+
+ * Added a few more test programs in various areas.
+
+ * Added Reverse a File test.
+
+ * Dave Thomas offered some tips to speed up some of the Ruby
+ programs.
+
+2000-11-21 (Doug Bagley)
+
+ * Roberto Ierusalimschy has kindly provided more Lua test programs
+ for the new tests, in particular fixing problems in the Lua code
+ I've been attempting :-)
+
+2000-11-20 (Doug Bagley)
+
+ * Started new tests: lists, random number generator, heapsort.
+
+2000-11-19 (Doug Bagley)
+
+ * Released version 0.1.5 with latest fixes.
+
+ * I fixed a bug in the benchtest part of the framework that caused
+ CPU times from successive runs to be added. After re-running all
+ tests, a few of the rankings have changed a little. The most
+ noticable is that Java tests now show much better because they are
+ not penalized as much for their very high startup costs. Other
+ than that, the ranking orders didn't change too much.
+
+ * Roberto Ierusalimschy has kindly provided a number of the Lua
+ test programs.
+
+2000-11-06 (Doug Bagley)
+
+ * Modified benchtest to use the GTop perl module. Hopefully this
+ will be good for portability (at least to other Unices).
+
+2000-10-16 (Doug Bagley)
+
+ * Added a couple of Tcl wordfreqs.
+
+ * Added a bigloo sumcol test.
+
+2000-10-15 (Doug Bagley)
+
+ * Added Icon version of sumcol test.
+
+2000-10-12 (Doug Bagley)
+
+ * Added gcc moments test.
+
+ * Now you can "make report" at top level or in bench/ to see which
+ languages implement which tests, and which tests still need to be
+ written.
+
+ * Added a Tcl version of Ackermann, it explodes due to stack
+ overflow.
+
+2000-10-11 (Doug Bagley)
+
+ * Added Haskell version of Ackermann test.
+
+2000-10-09 (Doug Bagley)
+
+ * Added mercury sieve test.
+
+ * Added bigloo sieve test. Added -O3 param to bigloo compile.
+
+2000-10-08 (Doug Bagley)
+
+ * Added a couple SML test.
+
+ * Released version 0.1.3.
+
+ * Started Statistical Moments test.
+
+2000-10-07 (Doug Bagley)
+
+ * Removed some CGI stuff, and now we create HTML tables for data
+ at build time.
+
+ * Added an Ackermann test for bigloo scheme.
+
+2000-10-05 (Doug Bagley)
+
+ * Started sumcol test.
+
+ * The Ruby Ackermann test completes now (with the upgrade from
+ 1.4.6 to 1.6.1).
+
+ * Added Mercury version of Ackermann test.
+
+2000-10-03 (Doug Bagley)
+
+ * Released version 0.1.2.
+
+ * Added OCAML version of Ackermann and Sieve tests.
+
+2000-10-02 (Doug Bagley)
+
+ * Added Bill Lear's C++ spell checker that uses mmap.
+
+ * Started ChangeLog.
+
+2000-09-30 (Doug Bagley)
+
+ * Updated Ruby from 1.4.6 to 1.6.1.
+
+ * Updated Erlang from R7A to R7B.
+
+ * Updated Guile from 1.3.4 to 1.4.
+
+ * Updated Lua from 4.0alpha to 4.0beta.
+
+ * Updated Rep from 0.12.4 to 0.13.1.
+
+ * Updated gforth from 0.4 to 0.5.
+
+ * Updated gawk from 3.0.4 to 3.0.6.
+
+2000-09-25 (Doug Bagley)
+
+ * Now tests can define a range over which measurements are taken. The
+ range can be number of iterations, size of input datasets or a
+ parameter passed to the test so it can use it as an input parameter.
+
+ * The first test in the range can be designated as the one used for
+ correctness testing (comparing with expected output). It can also
+ serve to make sure input data is cached.
+
+ * Re-generated test data over variable ranges of input, and results
+ are now on the detail page for each test. At the minimum end we see
+ effects of startup costs. At the maximum end, we see the test's
+ optimal performance.
+
+
47 Make.footer
@@ -0,0 +1,47 @@
+# Language Benchmark Shootout Makefile Footer
+# $Id: Make.footer,v 1.1 2004-05-19 18:08:56 bfulgham Exp $
+
+# common rules go here
+
+.PHONY: show clean clobber setup loc post
+
+############################################################
+# Targets normally called by user
+############################################################
+all: plot data/loc.tab post data/all.html
+
+plot: setup
+ @$(RUNTESTS)
+
+test: setup
+ @$(RUNTESTS) --repeat 1
+
+show: plot
+ @ee data/max.png &
+ @ee data/cpu.png &
+ @ee data/mem.png &
+ @ee data/min.png &
+
+clobber: clean
+ @echo "Clobbering data/*"
+ @rm -rf data
+
+clean:
+ @echo "Cleaning tmp/*"
+ @rm -rf tmp
+
+############################################################
+# generate .loc in tmp/
+############################################################
+
+loc: data/loc.tab
+ cat $^
+
+tmp/%.loc: %
+ ../../bin/loc $(LOCDEPS) $^ > $@
+
+data/loc.tab: $(foreach prog,$(filter-out %~,$(wildcard $(TEST).*)),tmp/$(prog).loc)
+ cat $^ | sort > $@
+
+data/all.html: data/max.mbtab data/loc.tab
+ ../../bin/make_all_html
51 Make.header
@@ -0,0 +1,51 @@
+# Language Benchmark Shootout Makefile Header
+# $Id: Make.header,v 1.1 2004-05-19 18:09:04 bfulgham Exp $
+
+############################################################
+# common definitions go here
+############################################################
+
+MINIBENCH := minibench --swapok #--debug
+
+BASH := /bin/bash
+BIGLOO := /usr/bin/bigloo
+CMUCL := /usr/bin/lisp
+ERLANG := /usr/bin/erl
+GAWK := /usr/bin/gawk
+GCC := /usr/bin/gcc
+GHC := /usr/bin/ghc
+GUILE := /usr/bin/guile
+GXX := /usr/bin/g++
+LUA := /usr/bin/lua
+MAWK := /usr/bin/mawk
+MLTON := /usr/bin/mlton
+MZSCHEME := /usr/bin/mzscheme
+OCAML := /usr/bin/ocamlopt
+OCAMLB := /usr/bin/ocamlc
+PERL := /usr/bin/perl
+PIKE := /usr/bin/pike
+PYTHON := /usr/bin/python
+RUBY := /usr/bin/ruby
+TCL := /usr/bin/tclsh
+XEMACS := /usr/bin/xemacs
+
+LANGS := $(BASH) $(BIGLOO) $(CMUCL) $(ERLANG) $(GAWK) \
+ $(GCC) $(GHC) $(GUILE) $(GXX) $(LUA) $(MAWK) \
+ $(MLTON) $(MZSCHEME) $(OCAML) $(OCAMLB) $(PERL) \
+ $(PIKE) $(PYTHON) $(RUBY) $(TCL) $(XEMACS)
+
+############################################################
+# we define a default rule to tell user what to do
+# if they just randomly type "make" here.
+############################################################
+default:
+ @echo "No default rule, try:"
+ @echo " make all # do almost everything"
+ @echo " make plot # create data and graphs"
+ @echo " make show # \"make plot\" and then display graphs"
+ @echo " make test # like \"make plot\", but run only one repetition of tests"
+ @echo " make clean # remove generated/data files to prep for full re-run"
+ @echo " make report # report which tests are written (or not)"
+
+.EXPORT_ALL_VARIABLES:
+
34 Makefile
@@ -0,0 +1,34 @@
+# $Id: Makefile,v 1.1 2004-05-19 18:08:56 bfulgham Exp $
+
+include Make.header
+
+all: versions
+ (cd bench ; make $@)
+ (cd bench ; make --no-print-directory report> report.txt)
+ make recent craps codelinks
+
+test plot show loc:
+ (cd bench ; make $@)
+
+clean:
+ (cd bench ; make $@)
+
+.PHONY: dist report recent versions craps codelinks
+
+versions: versions.html
+
+versions.html: $(LANGS) bin/make_versions langs.pl
+ bin/make_versions > versions.html.tmp && \
+ mv -f versions.html.tmp versions.html
+
+dist:
+ bin/make_dist
+
+report codelinks:
+ @(cd bench ; make --no-print-directory $@)
+
+craps:
+ @(cd bench ; make --no-print-directory $@) > .craps.table
+
+recent:
+ @bin/make_recent > recent.html
29 Minibench.conf
@@ -0,0 +1,29 @@
+# $Id: Minibench.conf,v 1.1 2004-05-19 18:09:04 bfulgham Exp $
+#
+repeat 3
+rundir tmp
+datdir tmp
+tabdir data
+commandline cmucl: $CMUCL -noinit -batch -eval '(load "%B.cmucl_run" :verbose nil :print nil)' %A
+commandline gawk: $GAWK -f ../%X %A
+commandline ghc: %X %A $MB_GHCRTS
+commandline mawk: $MAWK -f ../%X %A
+commandline erlang: $ERLANG $ERLFLAGS -noinput -s %T main %A
+commandline lua: $LUA $LUA_EXTRAS ../%X %A
+commandline python: $PYTHON %B.pyo %A
+commandline tcl: $TCL ../%X %A
+commandline xemacs: $XEMACS -vanilla -batch -load %B.elc -funcall main %A
+automake gcc,bigloo,erlang,ghc
+automake ocaml,se,g++,xemacs,ocamlb,cmucl,python,mlton,njs
+maxtime 600
+minsummary 1
+maxsummary 1
+makedirs 1
+tabulate 1
+text 1
+graph 1
+verbose 1
+makefile ../../Makefile.mb
+update_file ../.up_date
+runlog tmp
+compareoutput 1
18 Notes.txt
@@ -0,0 +1,18 @@
+
+Notes:
+- add new tests to:
+ - shootout/bench/Makefile
+ - shootout/craps.cgi
+ - shootout/index.shtml
+ - make symlinks for .ocaml -> ocamlb programs.
+- add new language:
+ - shortcuts/build.<lang>
+ - shootout/.htaccess (add extension as a text/plain type, if executable)
+ - shootout/Make.header
+ - shootout/Minibench.conf
+ - shootout/bench/hello/Minibench.conf
+ - shootout/bench/Makefile.mb (if needs to "compile")
+ - shootout/lang/<lang> (.cvsignore, index.shtml, allsrc.shtml)
+ - shootout/langs.pl
+ - bin/loc
+- do a "cvs update -d" after addition.
3  README
@@ -0,0 +1,3 @@
+To run the benchmarks, type "make"
+this will show you some fun targets to build.
+
7 Todo
@@ -0,0 +1,7 @@
+-*- mode: text -*-
+
+- languageshootout.org
+- db backend: postgresql
+- forums: propose test, comment on test, propose lang, comments
+ section for each test
+- remove Make dependancy and use only Perl
174 ack.shtml
@@ -0,0 +1,174 @@
+<!--#set var="TITLE" value="Computer Language Shootout Acknowledgements" -->
+<!--#set var="KEYWORDS" value="performance, benchmark, computer,
+algorithms, languages, compare, cpu, memory" -->
+<!--#include virtual="html/header.shtml" -->
+<!--#include virtual="nav.html" -->
+
+<h4>Acknowledgements</h4>
+<a name="Acks">
+
+<p>
+ I've received help and inspiration from various sources, friends and
+ friendly net-folks, and I'll try to mention them all here.
+<p>
+ At early stages of this project I came across two web pages that had
+ a lot of interesting stuff on benchmarking. I've used ideas on
+ methodology, benchmarks, and target languages from both of these
+ prior works, which are both useful for review in their own right
+ (but are a little dated at this point, IMHO).
+<ul>
+<li>
+ <a href="http://cm.bell-labs.com/cm/cs/who/bwk/interps/pap.html">
+ Timing Trials, or, the Trials of Timing: Experiments with Scripting
+ and User-Interface Languages</a> by Brian W. Kernighan and Christopher
+ J. Van Wyk. This is an interesting study to read, but it does have
+ some flaws (as I'm sure mine does, or any benchmark for that
+ matter). For instance, it uses Ackermann's function as a measure
+ of function call efficiency, which I feel is inappropriate. It's
+ probably better to test function call efficiency in an iterative
+ style, rather than a recursive style, because those languages that
+ implement tail-call elimination (like functional languages), will
+ perform vastly better due to that optimization.
+<li>
+ <a href="http://www.lib.uchicago.edu/keith/crisis/"> My Programming
+ Language Crisis</a> by Keith Waclena. Keith wrote a great <a
+ href="http://www.lib.uchicago.edu/keith/crisis/disclaimer.html">disclaimer</a>,
+ which I think pretty much applies almost word for word for this
+ project :-) Keith also came up with a very interesting method for
+ quantifying some more qualitative aspects of different computer
+ languages. Unfortunately, it's a little incomplete, and definately
+ out of date now, but he raises lots of good points.
+</ul>
+
+<p>
+ Here's a list of participants who have helped me to implement better
+ tests. Please also check the comments of the test programs where I
+ try to give accurate attribution if I did not write the test myself.
+ Needless to say, if you find any mistakes you can attribute them
+ solely to me!
+
+<ul>
+<li>
+ I'd like to thank my friend, Bill Lear, for most of the programs
+ written in <a href="lang/g++">C++/STL</a>.
+<li>
+ My friend, Phil Chu, helped with the Java Word Frequency test and
+ has been helpful in discussion of the benchmark framework.
+<li>
+ Another friend from work, Kerry Clendinning, wrote a very clever
+ first version of the C Word Frequency test, which inspired me to
+ write a not-so-clever, but slightly faster version.
+<li>
+ Maurice Castro, who I encountered on the erlang-questions mailing list,
+ kindly helped out with a few of the <a href="lang/erlang/">Erlang</a>
+ tests, including the Erlang word frequency program. He has a book on
+ Erlang: Erlang in Real Time (ISBN: 0864447434).
+<li>
+ Roberto Ierusalimschy, one of Lua's creators, was kind enough to
+ contribute many of the <a href="lang/lua/">Lua</a> programs.
+<li>
+ Dave Thomas gave me some tips to speed up some of my <a
+ href="lang/ruby/">Ruby</a> programs. Dave has a new book on Ruby:
+ <a
+ href="http://www1.fatbrain.com/asp/bookinfo/bookinfo.asp?theisbn=0201710897">
+ Programming Ruby: A Pragmatic Programmers Guide</a>. Check it out.
+<li>
+ Fredrik Noring from <a href="http://www.roxen.com">Roxen</a> along
+ with some of his friends and colleagues (Per Hedbor, Marcus
+ Comstedt, Henrik Grubbstr�m and Martin Nilsson) contributed a number
+ of the <a href="lang/pike/">Pike</a> programs. The <a
+ href="http://www.roxen.com/products/webserver/">Roxen WebServer</a>
+ and Roxen Platform are written in Pike.
+<li>
+ Hans Nowak has made some suggestions for improving the speed of some
+ of my <a href="lang/python/">Python</a> programs.
+<li>
+ Friedrich Dominicus sent me some suggestions for speeding up a few
+ programs. He has now sent a few <a
+ href="lang/se/">Eiffel</a> programs, and has contributed a number of
+ examples in <a href="lang/cmucl/">Common Lisp</a>.
+<li>
+ Tony Bowden helped me improve the speed of a couple <a
+ href="lang/perl/">Perl</a> programs.
+<li>
+ Benedikt Rosenau has contributed a number of new <a
+ href="lang/ocaml/">Ocaml</a>, <a href="lang/guile/">Guile/Goops</a>,
+ and <a href="lang/ghc/">Haskell</a> programs and has also suggested
+ improvements to some of my previous test programs.
+<li>
+ Kristoffer Lawson contributed a few <a href="lang/tcl/">Tcl</a>
+ programs, and gave me some hints to speed up some of my old ones.
+<li>
+ Miguel Sofer has also kindly offered a few faster <a
+ href="lang/tcl/">Tcl</a> programs.
+<li>
+ Markus Mottl has contributed new version of a number of <a
+ href="lang/ocaml/">Ocaml</a> programs, both speeding some up,
+ and making the code more beautiful and idiomatic.
+<li>
+ Steve Fink has contributed a couple of <a href="lang/bash/">bash</a>
+ program solutions, and has provided some speedups for a few <a
+ href="lang/perl/">Perl</a> programs.
+<li>
+ Brad Knotwell has contributed to some of the <a
+ href="lang/python/">Python</a> and <a href="lang/guile/">Guile</a>
+ programs.
+<li>
+ Sven Hartrumpf has offered some suggestion to improve timings of
+ <a href="lang/bigloo/">Bigloo</a> programs.
+<li>
+ Manuel Serrano, Bigloo's creator, has offered advice on how to write
+ <a href="lang/bigloo/">Bigloo</a> programs for performance.
+<li>
+ Julian Assange has contributed a number of new and improved <a
+ href="lang/ghc/">Haskell</a> programs.
+<li>
+ Steve Thompson contributed a number of the <a href="lang/se/">Eiffel</a>
+ programs.
+<li>
+ Mark Baker sent in a number of suggestions for speeding up <a
+ href="lang/python/">Python</a> code.
+<li>
+ Andrew Dalke also sent in a number of improvements to the <a
+ href="lang/python/">Python</a> programs.
+<li>
+ Larry Zappaterrini contributed information on <a
+ href="compare/binext/java/">using JNI to extend Java with C</a>.
+<li>
+ Ralph Becket helped out a lot with some <a
+ href="lang/mercury/">Mercury</a> programs.
+<li>
+ Fred Bremmer has helped improve the speed of some of the <a
+ href="lang/python/">Python</a> programs.
+<li>
+ Branko Vesligaj helped speed up a few of the <a href="lang/tcl/">Tcl</a>
+ programs noticeably.
+<li>
+ Anton Ertl has made some helpful suggestions about the shootout, and
+ has contributed a few of the <a href="lang/gforth/">GForth</a> solutions.
+<li>
+ Andrew D. McDowell has contributed some <a href="lang/cmucl/">Common
+ Lisp</a> programs.
+<li>
+ Danny Valenzuela (Dirus) helped out with some faster and cleaner
+ Java solutions.
+<li>
+ Stephen Weeks contributed a number of SML solutions for <a
+ href="lang/mlton/">MLton</a>, which I also used for <a
+ href="lang/smlnj/">SML/NJ</a>.
+<li>
+ Bulent Murtezaoglu has helped provide faster <a href="lang/cmucl/">Common
+ Lisp</a> programs.
+<li>
+ Jeff Siskind has helped porting some Scheme programs to his
+ <a href="lang/stalin/">Stalin</a> compiler.
+<li>
+ Paul Foley has contributed a few new version of the <a
+ href="lang/cmucl/">Common Lisp</a> programs.
+<li>
+ Bengt Kleberg has helped with the Scheme programs.
+<li>
+ Vasco Costa made some helpful comments about the C code.
+</ul
+</ul>
+<!--#include virtual="html/footer.shtml" -->
83 bench/Include/doubly_linked_list.e
@@ -0,0 +1,83 @@
+-- -*- mode: eiffel -*-
+-- $Id: doubly_linked_list.e,v 1.1 2004-05-19 18:09:06 bfulgham Exp $
+-- http://www.bagley.org/~doug/shootout/
+-- from Friedrich Dominicus
+
+class DOUBLY_LINKED_LIST[G]
+
+
+inherit
+ TWO_WAY_LINKED_LIST[G]
+
+
+creation
+ make
+
+
+feature
+ element : like first_link;
+
+
+ create_el_entry (elem: G): like first_link is
+ do
+ create Result.make(elem, Void, Void);
+ end;
+
+ print_list is
+ local
+ it : ITERATOR[G]
+ do
+
+ from it := get_new_iterator
+ until it.is_off
+ loop
+ io.put_string(it.item.out);
+ io.put_string(" ");
+ it.next;
+ end;
+ end;
+
+
+
+ revert_in_place is
+ local
+ tmp, act_element: like last_link
+
+ do
+ if (count > 1) then
+ -- special handling for the first change
+ -- this was done to make the loop as slim as possible
+ -- if that hasn't been done we had to check in each
+ -- loop whic makes a difference of at 10000
+ -- comparisons in the loop. Now we want to be fast
+ -- won't we ;-)
+ act_element := first_link;
+ tmp := last_link;
+ first_link := tmp;
+ last_link := last_link.previous;
+ last_link.set_next(Void);
+ tmp.set_previous (Void);
+ act_element.set_previous(tmp);
+ tmp.set_next(act_element);
+
+ from
+ until act_element.next = Void
+ loop
+ tmp := last_link;
+ last_link := last_link.previous;
+ last_link.set_next(Void);
+ tmp.set_previous (act_element.previous);
+ tmp.set_next(act_element);
+ act_element.previous.set_next(tmp);
+ act_element.set_previous(tmp);
+ end;
+ end -- if (count > 1)
+ last_link := act_element;
+ end
+
+
+
+
+
+
+end -- class DOUBLY_LINKED_LIST
62 bench/Include/hash_item.e
@@ -0,0 +1,62 @@
+-- AUTHOR: Jacques Bouchard <bouchard@mageos.com>
+-- http://mageos.ifrance.com/bouchard/
+
+class HASH_ITEM[V, K->HASHABLE]
+ --
+ -- Item of a HASH_MAP[V, K->HASHABLE]
+ --
+
+creation {HASH_MAP} make
+
+feature -- Accessing
+
+ value: V
+ -- Item value
+
+ key: K
+ -- Item key
+
+feature {HASH_MAP}
+
+ next: like Current
+
+feature -- Writing
+
+ set_value(v: like value) is
+ -- Set element value
+ do
+ value := v
+ ensure
+ value = v
+ end
+
+feature {HASH_MAP}
+
+ set_key(k: like key) is
+ do
+ key := k
+ ensure
+ key = k
+ end
+
+ set_next(n: like next) is
+ do
+ next := n
+ ensure
+ next = n
+ end
+
+feature {HASH_MAP}
+
+ make(v: like value; k: like key; n: like next) is
+ do
+ value := v
+ key := k
+ next := n
+ ensure
+ value = v
+ key = k
+ next = n
+ end
+
+end -- HASH_ITEM[V, K->HASHABLE]
340 bench/Include/hash_map.e
@@ -0,0 +1,340 @@
+-- AUTHOR: Jacques Bouchard <bouchard@mageos.com>
+-- http://mageos.ifrance.com/bouchard/
+
+class HASH_MAP[V, K->HASHABLE]
+ --
+ -- Associative memory (hash table implementation)
+ -- Values of type `V' are stored using keys of type `K'
+ --
+
+creation make, with_capacity
+
+feature {NONE} -- Internal storage management
+
+ buckets: FIXED_ARRAY[HASH_ITEM[V, K]]
+ -- Internal storage
+
+ new(capacity: INTEGER) is
+ -- Create an empty hash map in which `capacity' items
+ -- may be inserted without resizing the internal storage
+ do
+ !!buckets.make(buckets_opt_size(capacity))
+ ensure
+ buckets.lower = 0
+ buckets.count > 0
+ count = 0
+ end
+
+ hash_code(s: STRING): INTEGER is
+ local
+ i: INTEGER
+ do
+ from i := 1
+ until i > s.count
+ loop
+ Result := 5 * Result + (s @ i).code
+ i := i + 1
+ end
+ if Result < 0 then
+ Result := -(Result + 1)
+ end
+ end
+
+ resize(capacity: INTEGER) is
+ -- Resize the hash map so that it may contain `capacity' items
+ local
+ size, new_size: INTEGER
+ index, new_index: INTEGER
+ first, next: HASH_ITEM[V, K]
+ new_buckets: like buckets
+ do
+ size := buckets.count
+ if capacity > size then
+ new_size := buckets_opt_size(capacity)
+ if new_size > size then
+ !!new_buckets.make(new_size)
+ from
+ index := 0
+ until
+ index >= size
+ loop
+ from
+ first := buckets.item(index)
+ until
+ first = Void
+ loop
+ new_index := hash_code(first.key) \\ new_size
+ next := first.next
+ first.set_next(new_buckets.item(new_index))
+ new_buckets.put(first, new_index)
+ first := next
+ end
+ index := index + 1
+ end
+ buckets := new_buckets
+ end
+ end
+ ensure
+ buckets.lower = 0
+ buckets.count >= old buckets.count
+ count = old count
+ end
+
+ buckets_opt_size(capacity: INTEGER): INTEGER is
+ -- Return the optimal size of `buckets' array
+ -- for storing `capacity' items in the hash map
+ local
+ index: INTEGER
+ do
+ index := lower_bound(prime_list, capacity)
+ if index < prime_list.lower then
+ Result := prime_list.first
+ else
+ Result := prime_list.item(index)
+ end
+ ensure
+ Result > 0
+ end
+
+ lower_bound(array: ARRAY[INTEGER]; item: INTEGER): INTEGER is
+ -- Returns the highest index i for which array.item(i) <= item
+ -- or array.lower - 1 if array.first > item
+ require
+ array.count > 0
+ sorter.is_sorted(array)
+ local
+ min_index, max_index, index: INTEGER
+ do
+ from
+ min_index := array.lower
+ max_index := array.upper
+ until
+ max_index - min_index < 0
+ loop
+ index := (min_index + max_index) // 2
+ if array.item(index) <= item then
+ min_index := index + 1
+ else
+ max_index := index - 1
+ end
+ end
+ Result := min_index - 1
+ ensure
+ Result >= array.lower implies array.item(Result) <= item
+ Result < array.upper implies array.item(Result+1) > item
+ end
+
+ prime_list: ARRAY[INTEGER] is
+ -- Used by buckets_opt_size
+ once
+ Result := << 53, 97, 193, 389, 769,
+ 1543, 3079, 6151, 12289, 24593,
+ 49157, 98317, 196613, 393241, 786433,
+ 1572869, 3145739, 6291469, 12582917, 25165843,
+ 50331653, 100663319, 201326611, 402653189, 805306457,
+ 1610612741 >>
+ end
+
+ sorter: COLLECTION_SORTER[INTEGER] is
+ once
+ end
+
+feature -- Creation
+
+ make is
+ -- Create an empty hash map initialized with the default capacity
+ do
+ new(100)
+ ensure
+ count = 0
+ end
+
+ with_capacity(capacity: INTEGER) is
+ -- Create an empty hash map in which `capacity' items
+ -- may be inserted without resizing the internal storage
+ do
+ new(capacity)
+ ensure
+ count = 0
+ end
+
+feature -- Counting
+
+ count: INTEGER
+ -- number of items in the hash map
+
+feature -- Inserting
+
+ put (value: V; key: K) is
+ do
+ insert (value,key)
+ end
+
+ insert(value: V; key: K) is
+ -- Add a new item in the hash map, with key `key' and value `value'
+ require
+ key /= Void
+ find(key) = Void
+ local
+ index: INTEGER
+ item: HASH_ITEM[V, K]
+ do
+ resize(count + 1)
+ index := hash_code(key) \\ buckets.count
+ !!item.make(value, key, buckets.item(index))
+ buckets.put(item, index)
+ count := count + 1
+ ensure
+ find(key) /= Void
+ key.is_equal(find(key).key)
+ find(key).value = value
+ count = old count + 1
+ end
+
+feature -- Removing
+
+ remove (key: K) is
+ -- Remove the item with key `key' if it exists
+ require
+ key /= Void
+ local
+ index: INTEGER
+ item, prev: HASH_ITEM[V, K]
+ do
+ index := hash_code(key) \\ buckets.count
+ from
+ item := buckets.item(index)
+ until
+ item = Void or else
+ key.is_equal(item.key)
+ loop
+ prev := item
+ item := item.next
+ end
+ if item /= Void then
+ if prev = Void then
+ buckets.put(item.next, index)
+ else
+ prev.set_next(item.next)
+ end
+ count := count - 1
+ end
+ ensure
+ find(key) = Void
+ old find(key) = Void implies count = old count
+ old find(key) /= Void implies count = old count - 1
+ end
+
+ clear is
+ -- Discard all items
+ do
+ count := 0
+ buckets.clear_all
+ ensure
+ count = 0
+ end
+
+feature -- Searching
+
+ find(key: K): HASH_ITEM[V, K] is
+ -- Return the item with key `key' or `Void' if it doesn't exist
+ require
+ key /= Void
+ local
+ item: HASH_ITEM[V, K]
+ do
+ from
+ item := buckets.item(hash_code(key) \\ buckets.count)
+ until
+ item = Void or else
+ key.is_equal(item.key)
+ loop
+ item := item.next
+ end
+ Result := item
+ ensure
+ Result /= Void implies key.is_equal(Result.key)
+ count = old count
+ end
+
+ has (key: K) : BOOLEAN is
+ require
+ key /= Void
+ local
+ item: HASH_ITEM[V, K]
+ do
+ from
+ item := buckets.item(hash_code(key) \\ buckets.count)
+ until
+ item = Void or else
+ key.is_equal(item.key)
+ loop
+ item := item.next
+ end
+
+ if item = Void then
+ Result := false
+ else
+ Result := key.is_equal(item.key)
+ end
+ ensure
+ -- Result implies key.is_equal(item.key)
+ count = old count
+ end
+
+
+feature -- Traversing
+
+ start: HASH_ITEM[V, K] is
+ -- Return the first item or `Void' if it doesn't exist
+ local
+ index, size: INTEGER
+ do
+ size := buckets.count
+ from
+ index := 0
+ until
+ index >= size or else
+ buckets.item(index) /= Void
+ loop
+ index := index + 1
+ end
+ if index < size then
+ Result := buckets.item(index)
+ end
+ ensure
+ count > 0 implies Result /= Void
+ count = old count
+ end
+
+ forth(item: HASH_ITEM[V, K]): like item is
+ -- Return the next item or `Void' if it doesn't exist
+ require
+ item /= Void
+ local
+ size, index: INTEGER
+ do
+ Result := item.next
+ if Result = Void then
+ size := buckets.count
+ from
+ index := (hash_code(item.key) \\ size) + 1
+ until
+ index >= size or else
+ buckets.item(index) /= Void
+ loop
+ index := index + 1
+ end
+ if index < size then
+ Result := buckets.item(index)
+ end
+ end
+ ensure
+ count = old count
+ end
+
+invariant
+
+ count >= 0
+
+end -- HASH_MAP[V, K->HASHABLE]
197 bench/Include/meta.lisp
@@ -0,0 +1,197 @@
+;;; -*- mode: lisp -*-
+;;; $Id: meta.lisp,v 1.1 2004-05-19 18:09:07 bfulgham Exp $
+;;; http://www.bagley.org/~doug/shootout/
+;;; from Jochen Schmidt
+
+
+(defpackage "META"
+ (:use #:common-lisp)
+ (:export
+ #:with-string-meta
+ #:with-list-meta
+ #:with-stream-meta
+ #:enable-meta-syntax
+ #:disable-meta-syntax
+ #:index
+ #:end
+ #:match)
+ )
+
+(in-package :meta)
+
+
+;;; String matching
+(defmacro string-match (x &key source-symbol)
+ (etypecase x
+ (character
+ `(when (and (< index end) (eql (char ,source-symbol index) ,x))
+ (incf index)))
+ (string
+ (let ((old-index-symbol (gensym "OLD-INDEX-")))
+ `(let ((,old-index-symbol index))
+ (or (and ,@(map 'list #'(lambda (c) `(string-match ,c
+ :source-symbol ',source-symbol)) x))
+ (progn (setq index ,old-index-symbol) nil)))))))
+
+(defmacro string-match-type (x v &key source-symbol)
+ (let ((char-sym (gensym)))
+ `(when (< index end)
+ (let ((,char-sym (char ,source-symbol index)))
+ (declare (base-char ,char-sym))
+ (when (typep ,char-sym ',x)
+ (setq ,v ,char-sym) (incf index))))))
+
+
+;;; List matching
+(defmacro list-match (x &key source-symbol); sublist uses new lexical index
+ `(when (and (consp ,source-symbol)
+ ,(if (atom x) `(eql (car ,source-symbol) ',x)
+ `(let ((,source-symbol (car ,source-symbol))) ,(compile-list x :source-symbol source-symbol))))
+ (pop ,source-symbol) t))
+
+(defmacro list-match-type (x v &key source-symbol)
+ `(when (and (consp ,source-symbol) (typep (car ,source-symbol) ',x))
+ (setq ,v (car ,source-symbol)) (pop ,source-symbol) t))
+
+(defun compile-list (l &key source-symbol)
+ (if (atom l) `(eql ,source-symbol ',l)
+ `(and ,(compileit (car l) :meta-parser-type :list :source-symbol source-symbol)
+ ,(compile-list (cdr l) :source-symbol source-symbol))))
+
+
+;;; Stream matching
+(defmacro stream-match (x &key source-symbol)
+ `(when (eql (peek-char ,source-symbol) ',x) (read-char ,source-symbol)))
+
+(defmacro stream-match-type (x v &key source-symbol)
+ `(when (typep (peek-char ,source-symbol) ',x) (setq ,v (read-char ,source-symbol))))
+
+(defstruct (meta
+ (:print-function
+ (lambda (m s d &aux (char (meta-char m)) (form (meta-form m)))
+ (declare (ignore d))
+ (ecase char
+ ((#\@ #\! #\$) (format s "~A~A" char form))
+ (#\[ (format s "[~{~A~^ ~}]" form))
+ (#\{ (format s "{~{~A~^ ~}}" form))))))
+ char
+ form)
+
+
+(defun compileit (x &key meta-parser-type source-symbol)
+ (typecase x
+ (meta
+ (ecase (meta-char x)
+ (#\! (meta-form x))
+ (#\[ `(and ,@(mapcar #'(lambda (f) (compileit f
+ :meta-parser-type meta-parser-type
+ :source-symbol source-symbol))
+ (meta-form x))))
+ (#\{ `(or ,@(mapcar #'(lambda (f) (compileit f
+ :meta-parser-type meta-parser-type
+ :source-symbol source-symbol))
+ (meta-form x))))
+ (#\$ `(not (do () ((not ,(compileit (meta-form x)
+ :meta-parser-type meta-parser-type
+ :source-symbol source-symbol))))))
+ (#\@ (let ((f (meta-form x))) (list (ecase meta-parser-type
+ (:list 'list-match-type)
+ (:string 'string-match-type)
+ (:stream 'stream-match-type))
+ (car f) (cadr f)
+ :source-symbol source-symbol
+ )))))
+ (t (list (ecase meta-parser-type
+ (:list 'list-match)
+ (:string 'string-match)
+ (:stream 'stream-match))
+ x
+ :source-symbol source-symbol
+ ))))
+
+
+(eval-when (compile load eval)
+(defparameter *saved-readtable* (copy-readtable))
+(defparameter *meta-readtable* (copy-readtable))
+
+(defun meta-reader (s c) (make-meta :char c :form (read s)))
+
+
+(mapc #'(lambda (c) (set-macro-character c #'meta-reader nil *meta-readtable*)) '(#\@ #\$ #\!))
+
+(set-macro-character #\{
+ #'(lambda (s c) (make-meta :char c :form (read-delimited-list #\} s t))) nil *meta-readtable*)
+
+(set-macro-character #\[
+ #'(lambda (s c) (make-meta :char c :form (read-delimited-list #\] s t))) nil *meta-readtable*)
+
+(mapc #'(lambda (c) (set-macro-character c (get-macro-character #\)) nil *meta-readtable*))
+ '(#\] #\}))
+)
+
+(defmacro with-stream-meta ((source-symbol stream) &body body)
+ `(let ((,source-symbol ,stream))
+ (macrolet ((match (x)
+ (compileit x
+ :meta-parser-type :stream
+ :source-symbol ',source-symbol)))
+ ,@body)))
+
+(defmacro with-string-meta ((source-symbol string-buffer &key (start 0) end) &body body)
+ `(let* ((,source-symbol ,string-buffer)
+ (index ,start)
+ (end ,(or end `(length ,source-symbol))))
+ (declare (fixnum index end)
+ (type simple-base-string ,source-symbol))
+ (macrolet ((match (x)
+ (compileit x
+ :meta-parser-type :string
+ :source-symbol ',source-symbol)))
+ ,@body)))
+
+
+(defmacro with-list-meta ((source-symbol list) &body body)
+ `(let ((,source-symbol ,list))
+ (macrolet ((match (x)
+ (compileit x
+ :meta-parser-type :list
+ :source-symbol ',source-symbol)))
+ ,@body)))
+
+(defun enable-meta-syntax ()
+ (copy-readtable *meta-readtable* *readtable*))
+
+(defun disable-meta-syntax()
+ (copy-readtable *saved-readtable* *readtable*))
+
+
+#|
+
+(eval-when (compile load eval)
+ (deftype digit () '(member #\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9))
+
+ (deftype non-digit () '(not (member #\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9)))
+
+ (defun ctoi (d) (- (char-code d) #.(char-code #\0)))
+)
+
+(eval-when (compile load eval)
+ (enable-meta-syntax)
+)
+
+
+(defun parse-int (string &aux (s +1) d (n 0))
+ (with-string-meta (buffer string)
+ (and
+ (match
+ [{#\+ [#\- !(setq s -1)] []}
+ @(digit d) !(setq n (ctoi d))
+ $[@(digit d) !(setq n (+ (* n 10) (ctoi d)))]])
+ (* s n))))
+
+(eval-when (compile load eval)
+(disable-meta-syntax)
+)
+
+|#
+
39 bench/Include/nth_toggle.e
@@ -0,0 +1,39 @@
+-- -*- mode: eiffel -*-
+-- $Id: nth_toggle.e,v 1.1 2004-05-19 18:09:07 bfulgham Exp $
+-- http://www.bagley.org/~doug/shootout/
+-- from Steve Thompson
+
+class NTH_TOGGLE
+inherit TOGGLE
+ rename make as parent_make
+ redefine activate
+ end
+
+creation make
+
+feature -- Creation
+
+ make(start_state: BOOLEAN; max_counter: INTEGER) is
+ do
+ parent_make(start_state)
+ count_max := max_counter
+ counter := 0
+ end -- make
+
+feature -- Queries
+
+ count_max: INTEGER
+ counter: INTEGER
+
+ activate: like Current is
+ do
+ counter := counter + 1
+ if Current.counter >= Current.count_max then
+ state := state = False
+ counter := 0
+ end
+ Result := Current
+ end -- activate
+
+end -- class NTH_TOGGLE
+
33 bench/Include/randomnumber.e
@@ -0,0 +1,33 @@
+-- -*- mode: eiffel -*-
+-- $Id: randomnumber.e,v 1.1 2004-05-19 18:09:07 bfulgham Exp $
+-- http://www.bagley.org/~doug/shootout/
+-- from Steve Thompson
+
+class RANDOMNUMBER
+
+creation make
+
+feature -- Creation
+
+ make is
+ do
+ last := 42
+ end -- make
+
+feature -- Queries
+
+ IM: INTEGER is 139968
+
+ IA: INTEGER is 3877
+
+ IC: INTEGER is 29573
+
+ last: INTEGER
+
+ next(max: DOUBLE): DOUBLE is
+ do
+ last := (last * IA + IC) \\ IM
+ Result := max * last / IM
+ end -- next
+
+end
33 bench/Include/randomnumber.e_no_max
@@ -0,0 +1,33 @@
+-- -*- mode: eiffel -*-
+-- $Id: randomnumber.e_no_max,v 1.1 2004-05-19 18:09:07 bfulgham Exp $
+-- http://www.bagley.org/~doug/shootout/
+-- from Steve Thompson
+
+class RANDOMNUMBER
+
+creation make
+
+feature -- Creation
+
+ make is
+ do
+ last := 42
+ end -- make
+
+feature -- Queries
+
+ IM: INTEGER is 139968
+
+ IA: INTEGER is 3877
+
+ IC: INTEGER is 29573
+
+ last: INTEGER
+
+ next: DOUBLE is
+ do
+ last := (last * IA + IC) \\ IM
+ Result := last / IM
+ end -- next
+
+end
183 bench/Include/simple_hash.h
@@ -0,0 +1,183 @@
+/*
+ * $Id: simple_hash.h,v 1.1 2004-05-19 18:09:07 bfulgham Exp $
+ *
+ * simple hashtable map: Cstring -> Int
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+enum { ht_num_primes = 28 };
+
+static unsigned long ht_prime_list[ht_num_primes] = {
+ 53ul, 97ul, 193ul, 389ul, 769ul,
+ 1543ul, 3079ul, 6151ul, 12289ul, 24593ul,
+ 49157ul, 98317ul, 196613ul, 393241ul, 786433ul,
+ 1572869ul, 3145739ul, 6291469ul, 12582917ul, 25165843ul,
+ 50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul,
+ 1610612741ul, 3221225473ul, 4294967291ul
+};
+
+struct ht_node {
+ char *key;
+ int val;
+ struct ht_node *next;
+};
+
+struct ht_ht {
+ int size;
+ struct ht_node **tbl;
+ int iter_index;
+ struct ht_node *iter_next;
+ int items;
+#ifdef HT_DEBUG
+ int collisions;
+#endif /* HT_DEBUG */
+};
+
+inline int ht_val(struct ht_node *node) {
+ return(node->val);
+}
+
+inline char *ht_key(struct ht_node *node) {
+ return(node->key);
+}
+
+inline int ht_hashcode(struct ht_ht *ht, char *key) {
+ unsigned long val = 0;
+ for (; *key; ++key) val = 5 * val + *key;
+ return(val % ht->size);
+}
+
+struct ht_node *ht_node_create(char *key) {
+ char *newkey;
+ struct ht_node *node;
+ if ((node = (struct ht_node *)malloc(sizeof(struct ht_node))) == 0) {
+ perror("malloc ht_node");
+ exit(1);
+ }
+ if ((newkey = (char *)strdup(key)) == 0) {
+ perror("strdup newkey");
+ exit(1);
+ }
+ node->key = newkey;
+ node->val = 0;
+ node->next = (struct ht_node *)NULL;
+ return(node);
+}
+
+struct ht_ht *ht_create(int size) {
+ int i = 0;
+ struct ht_ht *ht = (struct ht_ht *)malloc(sizeof(struct ht_ht));
+ while (ht_prime_list[i] < size) { i++; }
+ ht->size = ht_prime_list[i];
+ ht->tbl = (struct ht_node **)calloc(ht->size, sizeof(struct ht_node *));
+ ht->iter_index = 0;
+ ht->iter_next = 0;
+ ht->items = 0;
+#ifdef HT_DEBUG
+ ht->collisions = 0;
+#endif /* HT_DEBUG */
+ return(ht);
+}
+
+void ht_destroy(struct ht_ht *ht) {
+ struct ht_node *cur, *next;
+ int i;
+#ifdef HT_DEBUG
+ int chain_len;
+ int max_chain_len = 0;
+ int density = 0;
+ fprintf(stderr, " HT: size %d\n", ht->size);
+ fprintf(stderr, " HT: items %d\n", ht->items);
+ fprintf(stderr, " HT: collisions %d\n", ht->collisions);
+#endif /* HT_DEBUG */
+ for (i=0; i<ht->size; i++) {
+ next = ht->tbl[i];
+#ifdef HT_DEBUG
+ if (next) {
+ density++;
+ }
+ chain_len = 0;
+#endif /* HT_DEBUG */
+ while (next) {
+ cur = next;
+ next = next->next;
+ free(cur->key);
+ free(cur);
+#ifdef HT_DEBUG
+ chain_len++;
+#endif /* HT_DEBUG */
+ }
+#ifdef HT_DEBUG
+ if (chain_len > max_chain_len)
+ max_chain_len = chain_len;
+#endif /* HT_DEBUG */
+ }
+ free(ht->tbl);
+ free(ht);
+#ifdef HT_DEBUG
+ fprintf(stderr, " HT: density %d\n", density);
+ fprintf(stderr, " HT: max chain len %d\n", max_chain_len);
+#endif /* HT_DEBUG */
+}
+
+inline struct ht_node *ht_find(struct ht_ht *ht, char *key) {
+ int hash_code = ht_hashcode(ht, key);
+ struct ht_node *node = ht->tbl[hash_code];
+ while (node) {
+ if (strcmp(key, node->key) == 0) return(node);
+ node = node->next;
+ }
+ return((struct ht_node *)NULL);
+}
+
+inline struct ht_node *ht_find_new(struct ht_ht *ht, char *key) {
+ int hash_code = ht_hashcode(ht, key);
+ struct ht_node *prev = 0, *node = ht->tbl[hash_code];
+ while (node) {
+ if (strcmp(key, node->key) == 0) return(node);
+ prev = node;
+ node = node->next;
+#ifdef HT_DEBUG
+ ht->collisions++;
+#endif /* HT_DEBUG */
+ }
+ ht->items++;
+ if (prev) {
+ return(prev->next = ht_node_create(key));
+ } else {
+ return(ht->tbl[hash_code] = ht_node_create(key));
+ }
+}
+
+/*
+ * Hash Table iterator data/functions
+ */
+inline struct ht_node *ht_next(struct ht_ht *ht) {
+ unsigned long index;
+ struct ht_node *node = ht->iter_next;
+ if (node) {
+ ht->iter_next = node->next;
+ return(node);
+ } else {
+ while (ht->iter_index < ht->size) {
+ index = ht->iter_index++;
+ if (ht->tbl[index]) {
+ ht->iter_next = ht->tbl[index]->next;
+ return(ht->tbl[index]);
+ }
+ }
+ }
+ return((struct ht_node *)NULL);
+}
+
+inline struct ht_node *ht_first(struct ht_ht *ht) {
+ ht->iter_index = 0;
+ ht->iter_next = (struct ht_node *)NULL;
+ return(ht_next(ht));
+}
+
+inline int ht_count(struct ht_ht *ht) {
+ return(ht->items);
+}
204 bench/Include/simple_hash2.h
@@ -0,0 +1,204 @@
+/*
+ * $Id: simple_hash2.h,v 1.1 2004-05-19 18:09:09 bfulgham Exp $
+ *
+ * simple hashtable map: Cstring -> Int
+ * Changed by Adrian Merrill 2001/09/21 (added the ablity to calculate the hash code byte by byte)
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#define QUICKIE_STRCMP(a, b) (*(a) != *(b) ? *(a) - *(b) : strcmp((a), (b)))
+#define HASHCODE_BYTE(val,key) val = 5 * val + key
+#define HASHCODE_FINALIZE(val,ht) val % ht->size
+
+enum { ht_num_primes = 28 };
+
+static unsigned long ht_prime_list[ht_num_primes] = {
+ 53ul, 97ul, 193ul, 389ul, 769ul,
+ 1543ul, 3079ul, 6151ul, 12289ul, 24593ul,
+ 49157ul, 98317ul, 196613ul, 393241ul, 786433ul,
+ 1572869ul, 3145739ul, 6291469ul, 12582917ul, 25165843ul,
+ 50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul,
+ 1610612741ul, 3221225473ul, 4294967291ul
+};
+
+struct ht_node {
+ char *key;
+ int val;
+ struct ht_node *next;
+};
+
+struct ht_ht {
+ int size;
+ struct ht_node **tbl;
+ int iter_index;
+ struct ht_node *iter_next;
+ int items;
+#ifdef HT_DEBUG
+ int collisions;
+#endif /* HT_DEBUG */
+};
+
+inline int ht_val(struct ht_node *node) {
+ return(node->val);
+}
+
+inline char *ht_key(struct ht_node *node) {
+ return(node->key);
+}
+
+inline int ht_hashcode(struct ht_ht *ht, char *key) {
+ unsigned long val = 0;
+ for (; *key; ++key) HASHCODE_BYTE(val,*key);
+ return(HASHCODE_FINALIZE(val,ht));
+}
+
+struct ht_node *ht_node_create(char *key) {
+ struct ht_node *node;
+ if ((node = (struct ht_node *)malloc(sizeof(struct ht_node))) == 0) {
+ perror("malloc ht_node");
+ exit(1);
+ }
+ if ((node->key = (char *)strdup(key)) == 0) {
+ perror("strdup newkey");
+ exit(1);
+ }
+ node->val = 0;
+ node->next = (struct ht_node *)NULL;
+ return(node);
+}
+
+struct ht_ht *ht_create(int size) {
+ int i = 0;
+ struct ht_ht *ht = (struct ht_ht *)malloc(sizeof(struct ht_ht));
+ while (ht_prime_list[i] < size) { i++; }
+ ht->size = ht_prime_list[i];
+ ht->tbl = (struct ht_node **)calloc(ht->size, sizeof(struct ht_node *));
+ ht->iter_index = 0;
+ ht->iter_next = 0;
+ ht->items = 0;
+#ifdef HT_DEBUG
+ ht->collisions = 0;
+#endif /* HT_DEBUG */
+ return(ht);
+}
+
+void ht_destroy(struct ht_ht *ht) {
+ struct ht_node *cur, *next;
+ int i;
+#ifdef HT_DEBUG
+ int chain_len;
+ int max_chain_len = 0;
+ int density = 0;
+ fprintf(stderr, " HT: size %d\n", ht->size);
+ fprintf(stderr, " HT: items %d\n", ht->items);
+ fprintf(stderr, " HT: collisions %d\n", ht->collisions);
+#endif /* HT_DEBUG */
+ for (i=0; i<ht->size; i++) {
+ next = ht->tbl[i];
+#ifdef HT_DEBUG
+ if (next) {
+ density++;
+ }
+ chain_len = 0;
+#endif /* HT_DEBUG */
+ while (next) {
+ cur = next;
+ next = next->next;
+ free(cur->key);
+ free(cur);
+#ifdef HT_DEBUG
+ chain_len++;
+#endif /* HT_DEBUG */
+ }
+#ifdef HT_DEBUG
+ if (chain_len > max_chain_len)
+ max_chain_len = chain_len;
+#endif /* HT_DEBUG */
+ }
+ free(ht->tbl);
+ free(ht);
+#ifdef HT_DEBUG
+ fprintf(stderr, " HT: density %d\n", density);
+ fprintf(stderr, " HT: max chain len %d\n", max_chain_len);
+#endif /* HT_DEBUG */
+}
+
+inline struct ht_node *ht_find(struct ht_ht *ht, char *key) {
+ int hash_code = ht_hashcode(ht, key);
+ struct ht_node *node = ht->tbl[hash_code];
+ while (node) {
+ if (QUICKIE_STRCMP(key, node->key) == 0) return(node);
+ node = node->next;
+ }
+ return((struct ht_node *)NULL);
+}
+
+inline struct ht_node *ht_find_new_prehashed(struct ht_ht *ht, char *key,int hash_code) {
+ struct ht_node *prev = 0, *node = ht->tbl[hash_code];
+ while (node) {
+ if (QUICKIE_STRCMP(key, node->key) == 0) return(node);
+ prev = node;
+ node = node->next;
+#ifdef HT_DEBUG
+ ht->collisions++;
+#endif /* HT_DEBUG */
+ }
+ ht->items++;
+ if (prev) {
+ return(prev->next = ht_node_create(key));
+ } else {
+ return(ht->tbl[hash_code] = ht_node_create(key));
+ }
+}
+
+inline struct ht_node *ht_find_new(struct ht_ht *ht, char *key) {
+ int hash_code = ht_hashcode(ht, key);
+ struct ht_node *prev = 0, *node = ht->tbl[hash_code];
+ while (node) {
+ if (QUICKIE_STRCMP(key, node->key) == 0) return(node);
+ prev = node;
+ node = node->next;
+#ifdef HT_DEBUG
+ ht->collisions++;
+#endif /* HT_DEBUG */
+ }
+ ht->items++;
+ if (prev) {
+ return(prev->next = ht_node_create(key));
+ } else {
+ return(ht->tbl[hash_code] = ht_node_create(key));
+ }
+}
+
+/*
+ * Hash Table iterator data/functions
+ */
+inline struct ht_node *ht_next(struct ht_ht *ht) {
+ unsigned long index;
+ struct ht_node *node = ht->iter_next;
+ if (node) {
+ ht->iter_next = node->next;
+ return(node);
+ } else {
+ while (ht->iter_index < ht->size) {
+ index = ht->iter_index++;
+ if (ht->tbl[index]) {
+ ht->iter_next = ht->tbl[index]->next;
+ return(ht->tbl[index]);
+ }
+ }
+ }
+ return((struct ht_node *)NULL);
+}
+
+inline struct ht_node *ht_first(struct ht_ht *ht) {
+ ht->iter_index = 0;
+ ht->iter_next = (struct ht_node *)NULL;
+ return(ht_next(ht));
+}
+
+inline int ht_count(struct ht_ht *ht) {
+ return(ht->items);
+}
32 bench/Include/toggle.e
@@ -0,0 +1,32 @@
+-- -*- mode: eiffel -*-
+-- $Id: toggle.e,v 1.1 2004-05-19 18:09:09 bfulgham Exp $
+-- http://www.bagley.org/~doug/shootout/
+-- from Steve Thompson
+
+class TOGGLE
+
+creation make
+
+feature -- Creation
+
+ make(start_state: BOOLEAN) is
+ do
+ state := start_state
+ end
+
+feature -- Queries
+
+ state: BOOLEAN
+
+ value: BOOLEAN is
+ do
+ Result := state
+ end -- value
+
+ activate: like Current is
+ do
+ state := state = False
+ Result := Current
+ end -- activate
+
+end -- class TOGGLE
43 bench/Makefile
@@ -0,0 +1,43 @@
+# $Id: Makefile,v 1.1 2004-05-19 18:09:05 bfulgham Exp $
+
+TESTS = \
+ hello \
+ ackermann \
+ ary3 \
+ echo \
+ except \
+ fibo \
+ hash \
+ hash2 \
+ heapsort \
+ lists \
+ matrix \
+ methcall \
+ moments \
+ nestedloop \
+ objinst \
+ prodcons \
+ random \
+ regexmatch \
+ reversefile \
+ sieve \
+ spellcheck \
+ strcat \
+ sumcol \
+ wc \
+ wordfreq
+
+.PHONY: all plot test show clean clobber report
+
+all plot test loc show clean clobber:
+ @for t in $(TESTS) ; do (cd $$t && make $@) ; done
+
+report: $(filter-out %.ocamlb,$(foreach dir,$(TESTS),$(wildcard $(dir)/$(dir).*)))
+ @../bin/make_report $^
+
+codelinks: $(TESTS)
+ @../bin/make_codelinks $^
+
+craps: $(TESTS)
+ @../bin/make_craps $^
+
225 bench/Makefile.mb
@@ -0,0 +1,225 @@
+# $Id: Makefile.mb,v 1.1 2004-05-19 18:09:05 bfulgham Exp $
+include ../../../Make.header
+
+############################################################
+# common definitions go here
+############################################################
+
+# Eiffel needs a little work to get it going ...
+SmallEiffel := /usr/lib/smarteiffel
+SE := $(SmallEiffel)/bin/compile
+CLEAN_SE := $(SmallEiffel)/bin/clean
+SE_OPTS := -boost -no_split -O3 $(SE_OPTS)
+
+GCCOPTS := -pipe -Wall -O3 -fomit-frame-pointer $(GCCOPTS)
+GXXOPTS := -pipe -Wall -O2 -fomit-frame-pointer $(GXXOPTS)
+GXXLDOPTS := -L/usr/local/lib $(GXXLDOPTS)
+OCAMLOPTS := -noassert -unsafe -I /usr/local/lib/ocaml/contrib -ccopt -O3 $(OCAMLOPTS)
+OCAMLBOPTS := -noassert -unsafe -I /usr/local/lib/ocaml/contrib $(OCAMLBOPTS)
+BIGLOOOPTS := -fsharing -Obench -unsafe $(BIGLOOOPTS)
+GHCOPTS := -O $(GHCOPTS)
+
+.EXPORT_ALL_VARIABLES:
+
+##################################################
+# common rules go here
+##################################################
+
+# some definitions used by the rules
+.PHONY: plot show clean clobber test
+
+############################################################
+# Targets normally called by user
+############################################################
+show: plot
+ @ee data/max.png &
+ @ee data/cpu.png &
+ @ee data/mem.png &
+ @ee data/min.png &
+
+clobber: clean
+ @echo "Clobbering data/*"
+ @rm -rf data
+
+clean:
+ @echo "Cleaning tmp/*"
+ @rm -rf tmp
+
+############################################################
+# for source files that need to be built/compiled
+############################################################
+
+########################################
+# gcc
+########################################
+%.c: $(MB_SRCDIR)/%.gcc $(GCC)
+ @cp $< $@
+
+%.gcc_run: %.c $(GCC)
+ $(GCC) $(GCCOPTS) $< -o $@
+
+
+########################################
+# g++
+########################################
+%.c++: $(MB_SRCDIR)/%.g++ $(GXX)
+ @cp $< $@
+
+%.g++_run: %.c++
+ $(GXX) -c $(GXXOPTS) $< -o $<.o && \
+ $(GXX) $<.o -o $@ $(GXXLDOPTS)
+
+
+########################################
+# SmartEiffel
+########################################
+%.e: $(MB_SRCDIR)/%.se $(SE)
+ @echo "copying $< to $(TEST).e"
+ cp $< $(TEST).e
+
+%.se_run: %.e
+ rm -f $@
+ (echo . ; echo ../ ; echo ../../Include/) > loadpath.se
+ $(SE) $(SE_OPTS) -o $@ $(TEST) ; $(CLEAN_SE) $(TEST)
+
+
+########################################
+# Erlang
+########################################
+%.erlang_run: $(MB_SRCDIR)/%.erlang $(ERLANG)
+ cp $< $(TEST).erl
+ $(ERLANG) -compile $(TEST)
+ touch $@
+
+
+########################################
+# lua
+########################################
+%.lua_run: $(MB_SRCDIR)/%.lua $(LUA)
+ cp $< $@
+ @echo "lua -e NUM=%ARG $@"
+
+
+########################################
+# ocaml native code compiler
+########################################
+%.ml: $(MB_SRCDIR)/%.ocaml $(OCAML)
+ cp $< $@
+
+%.ocaml_run: %.ml
+ $(OCAML) $(OCAMLOPTS) $< -o $@
+
+
+########################################
+# ocaml bytecode compiler
+########################################
+%.ml: $(MB_SRCDIR)/%.ocamlb $(OCAMLB)
+ cp $< $@
+
+%.ocamlb_run: %.ml
+ $(OCAMLB) $(OCAMLBOPTS) $< -o $@
+
+
+########################################
+# mlton
+########################################
+%.sml: $(MB_SRCDIR)/%.mlton $(MLTON)
+ cat $(MLTONDEPS) $< > $@
+
+%.mlton_run: %.sml
+ $(MLTON) $^ && mv $(basename $(<F)) $(basename $(<F)).mlton_run
+
+########################################
+# bigloo
+########################################
+%.scm: $(MB_SRCDIR)/%.bigloo $(BIGLOO)
+ cp $< $@
+
+.PRECIOUS: %.scm
+
+%.bigloo_run: %.scm
+ $(BIGLOO) $(BIGLOOOPTS) $(<F) -o $(@F)
+
+########################################
+# sml/nj
+########################################
+%.x86-linux: $(MB_SRCDIR)/%.smlnj $(SMLNJ)
+ @rm -f $@
+ cat $< | $(SMLNJ)
+
+.PRECIOUS: %.x86-linux
+
+%.smlnj_run: %.x86-linux
+ @:
+
+########################################
+# ghc (glasgow haskell compiler)
+########################################
+%.hs: $(MB_SRCDIR)/%.ghc $(GHC)
+ cp $< $@
+
+%.ghc_run: %.hs
+ $(GHC) $(GHCOPTS) $< -o $@
+
+########################################
+# XEmacs :-)
+########################################
+%.el: $(MB_SRCDIR)/%.xemacs $(XEMACS)
+ cp $< $@
+
+.PRECIOUS: %.elc
+
+%.elc: %.el
+ $(XEMACS) -vanilla -batch -f batch-byte-compile $<
+
+%.xemacs_run: %.elc
+ @:
+
+########################################
+# CMUCL (Common Lisp)
+########################################
+# (Note: arg to compile-file for trace: ':trace-file t')
+CMUCL_TRACE :=
+#CMUCL_TRACE := :trace-file t
+%.cmucl_run: $(MB_SRCDIR)/%.cmucl $(CMUCL_SRCS) $(CMUCL)
+ @rm -f $@ ; \
+ echo "(proclaim '(optimize (speed 3) (safety 0) (debug 0) (compilation-speed 0) (space 0)))" > $@ ; \
+ echo "(setq *gc-verbose* nil)" >> $@ ; \
+ COMPILE=$@; COMPILE=$${COMPILE%_run}_compile ; \
+ FILES="" ; \
+ for f in $(CMUCL_SRCS) ; do cp $$f . ; FILES="$$FILES $${f##*/}" ; done ; \
+ echo "(proclaim '(optimize (speed 3) (safety 0) (debug 0) (compilation-speed 0) (space 0)))" > $$COMPILE ; \
+ for src in $$FILES ; do \
+ echo "(compile-file \"$$src\" :block-compile t $(CMUCL_TRACE)) (load \"$$src\" :verbose nil :print nil)" >> $$COMPILE ; \
+ base=$${src%.*} ; \
+ echo "(load \"$$base.x86f\" :verbose nil :print nil)" >> $@ ; \
+ done ; \
+ cp $< . ; MAIN=$< ; MAIN=$${MAIN##*/} ; \
+ (echo "(compile-file \"$$MAIN\" :block-compile t $(CMUCL_TRACE) :entry-points '(main))"; echo "(quit)") >> $$COMPILE ; \
+ MAIN=$${MAIN%.*} ; MAIN="$${MAIN}.x86f" ; echo "(load \"$$MAIN\" :verbose nil :print nil)" >> $@ ; \
+ echo "CMUCL built with: $(CMUCL) -noinit -batch -eval '(load \"$$COMPILE\")'" ; \
+ echo "### START $$COMPILE" ; cat $$COMPILE ; echo "### END $$COMPILE" ; echo ; \
+ $(CMUCL) -noinit -batch -eval "(load \"$$COMPILE\")" ; \
+ echo "(main) (quit)" >> $@
+ @echo "### START $@" ; cat $@ ; echo "### END $@" ; echo
+
+########################################
+# Python
+########################################
+%.py: $(MB_SRCDIR)/%.python $(PYTHON)
+ cp $< $@
+
+.PRECIOUS: %.pyo
+
+%.pyo: %.py
+ $(PYTHON) -OO -c "from py_compile import compile; compile('$<')"
+
+%.python_run: %.pyo
+ @:
+
+########################################
+# MzScheme
+########################################
+%.ss: $(MB_SRCDIR)/%.mzscheme $(MZSCHEME)
+ cp $< $@
+
1  bench/ackermann/.up_date
@@ -0,0 +1 @@
+Tue May 18 20:04:49 2004
12 bench/ackermann/Makefile
@@ -0,0 +1,12 @@
+# $Id: Makefile,v 1.1 2004-05-19 18:09:09 bfulgham Exp $
+include ../../Make.header
+
+TEST := ackermann
+TITLE := Ackermann's Function
+
+RUNTESTS := $(MINIBENCH) --conf ../../Minibench.conf --range 4,5,6,7,8 \
+ --ignore ackermann.tcl \
+ --ignore ackermann.bash \
+ --title "$(TITLE)" $(TEST).*
+
+include ../../Make.footer
1  bench/ackermann/Output
@@ -0,0 +1 @@
+Ack(3,4): 125
20 bench/ackermann/ackermann.bash
@@ -0,0 +1,20 @@
+#!/bin/bash
+# $Id: ackermann.bash,v 1.1 2004-05-19 18:09:09 bfulgham Exp $
+# http://www.bagley.org/~doug/shootout/
+# from Steve Fink
+
+function Ack () {
+ if [ $1 -eq 0 ]; then
+ Ack=$[ $2 + 1 ]
+ elif [ $2 -eq 0 ]; then
+ Ack $[ $1 - 1 ] 1
+ else
+ Ack $1 $[ $2 - 1 ]
+ local SubAck=$Ack
+ Ack $[ $1 - 1 ] $SubAck
+ fi
+}
+
+n=${1:-1}
+Ack 3 $n
+echo "Ack(3,$n): $Ack"
18 bench/ackermann/ackermann.bigloo
@@ -0,0 +1,18 @@
+;;; -*- mode: scheme -*-
+;;; $Id: ackermann.bigloo,v 1.1 2004-05-19 18:09:09 bfulgham Exp $
+;;; http://www.bagley.org/~doug/shootout/
+
+(module ackermann
+ (main main)
+ (option (set! *genericity* #f)))
+
+(define (main args)
+ (let ((n (or (and (= (length args) 2) (string->number (cadr args))) 1)))
+ (print-list "Ack(3," n "): " (ack 3 n))))
+
+(define (ack m n)
+ (cond ((zero? m) (+ n 1))
+ ((zero? n) (ack (- m 1) 1))
+ (else (ack (- m 1) (ack m (- n 1))))))
+
+(define (print-list . items) (for-each display items) (newline))
22 bench/ackermann/ackermann.cmucl
@@ -0,0 +1,22 @@
+;;; -*- mode: lisp -*-
+;;; $Id: ackermann.cmucl,v 1.1 2004-05-19 18:09:09 bfulgham Exp $
+;;; http://www.bagley.org/~doug/shootout/
+;;; From: Friedrich Dominicus
+
+(defun fast-ack (m n)
+ (declare (fixnum n m) (optimize (speed 3) (debug 0) (safety 0)))
+ (the fixnum
+ (cond
+ ((zerop m) (the fixnum (1+ n)))
+ ((zerop n) (the fixnum (fast-ack (1- m) 1)))
+ (t (the fixnum (fast-ack (1- m) (the fixnum (fast-ack m (1- n)))))))))
+
+;(defun ack (m n)
+; (cond
+; ((zerop m) (1+ n))
+; ((zerop n) (ack (1- m) 1))
+; (t (ack (1- m) (ack m (1- n))))))
+
+(defun main ()
+ (let ((n (parse-integer (or (car (last extensions:*command-line-strings*)) "1"))))
+ (format t "Ack(3,~A): ~A~%" n (fast-ack 3 n))))
16 bench/ackermann/ackermann.erlang
@@ -0,0 +1,16 @@
+%%% -*- mode: erlang -*-
+%%% $Id: ackermann.erlang,v 1.1 2004-05-19 18:09:09 bfulgham Exp $
+%%% http://www.bagley.org/~doug/shootout/
+
+-module(ackermann).
+-export([main/1]).
+
+main() -> main(['1']).
+main([Arg]) ->
+ Num = list_to_integer(atom_to_list(Arg)),
+ io:fwrite("Ack(3,~w): ~w\n", [Num, ack(3, Num)]),
+ halt(0).
+
+ack(0, N) -> N+1;
+ack(M, 0) -> ack(M-1, 1);
+ack(M, N) -> ack(M-1, ack(M, N-1)).
17 bench/ackermann/ackermann.g++
@@ -0,0 +1,17 @@
+// -*- mode: c++ -*-
+// $Id: ackermann.g++,v 1.1 2004-05-19 18:09:09 bfulgham Exp $
+// http://www.bagley.org/~doug/shootout/
+
+#include <iostream>
+#include <stdlib.h>
+
+using namespace std;
+
+int Ack(int M, int N) { return(M ? (Ack(M-1,N ? Ack(M,(N-1)) : 1)) : N+1); }
+
+int main(int argc, char *argv[]) {
+ int n = ((argc == 2) ? atoi(argv[1]) : 1);