-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add copies of most recent Clojure versions I could find from archive.org
- Loading branch information
1 parent
0823e63
commit 4b07637
Showing
21 changed files
with
1,865 additions
and
13 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
2017-mar-31-benchmarks-game-site-versions/binarytrees-notes.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
notes, command-line, and program output | ||
NOTES: | ||
64-bit Ubuntu quad core | ||
Clojure 1.8.0 | ||
java version "1.8.0_45" | ||
Java(TM) SE Runtime Environment (build 1.8.0_45-b14) | ||
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode) | ||
|
||
|
||
Sat, 27 Feb 2016 17:29:02 GMT | ||
|
||
MAKE: | ||
mv binarytrees.clojure-2.clojure binarytrees.clj | ||
/usr/local/src/jdk1.8.0_45/bin/java -Dclojure.compiler.direct-linking=true -Dclojure.compile.path=. -cp .:/usr/local/src/clojure/clojure-1.8.0.jar clojure.lang.Compile binarytrees | ||
Compiling binarytrees to . | ||
1.21s to complete and log all make actions | ||
|
||
COMMAND LINE: | ||
/usr/local/src/jdk1.8.0_45/bin/java -server -XX:+TieredCompilation -XX:+AggressiveOpts -cp .:/usr/local/src/clojure/clojure-1.8.0.jar binarytrees 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
;; The Computer Language Benchmarks Game | ||
;; http://benchmarksgame.alioth.debian.org/ | ||
|
||
;; Adapted from the Java -server version | ||
;; contributed by Marko Kocic | ||
;; modified by Kenneth Jonsson, restructured to allow usage of 'pmap' | ||
;; modified by Andy Fingerhut to use faster primitive math ops, and | ||
;; deftype instead of defrecord for smaller tree nodes. | ||
;; modified by Rich Hickey for Clojure 1.3 | ||
;; modified promise/delivery improvement by Stuart Halloway | ||
;; small hints by David Nolen and Alex Miller | ||
; | ||
(ns binarytrees | ||
(:gen-class)) | ||
|
||
(set! *warn-on-reflection* true) | ||
(set! *unchecked-math* true) | ||
|
||
(def ^:const ^long min-depth 4) | ||
|
||
(deftype TreeNode [left right ^long item]) | ||
|
||
(defn make-tree [^long item ^long depth] | ||
(if (zero? depth) | ||
(TreeNode. nil nil item) | ||
(let [i2 (* 2 item) | ||
ddec (dec depth)] | ||
(TreeNode. (make-tree (dec i2) ddec) (make-tree i2 ddec) item)))) | ||
|
||
(defn item-check ^long [^TreeNode node] | ||
(if (nil? (.left node)) | ||
(.item node) | ||
(- (+ (.item node) | ||
(item-check (.left node))) | ||
(item-check (.right node))))) | ||
|
||
(defn iterate-trees [^long mx ^long mn ^long d] | ||
(let [iterations (bit-shift-left 1 (long (+ mx mn (- d))))] | ||
(format "%d\t trees of depth %d\t check: %d" | ||
(* 2 iterations) | ||
d | ||
(loop [result 0 | ||
i 1] | ||
(if (= i (inc iterations)) | ||
result | ||
(recur (+ result | ||
(item-check (make-tree i d)) | ||
(item-check (make-tree (- i) d))) | ||
(inc i))))))) | ||
|
||
(defn main [^long max-depth] | ||
(let [stretch-depth (inc max-depth)] | ||
(let [tree (make-tree 0 stretch-depth) | ||
check (item-check tree)] | ||
(println (format "stretch tree of depth %d\t check: %d" stretch-depth check))) | ||
(let [agents (repeatedly (.availableProcessors (Runtime/getRuntime)) #(agent [])) | ||
long-lived-tree (make-tree 0 max-depth)] | ||
(loop [depth min-depth | ||
[a & more] (cycle agents) | ||
results []] | ||
(if (> depth stretch-depth) | ||
(doseq [r results] (println @r)) | ||
(let [result (promise)] | ||
(send a (fn [_] | ||
(deliver result (iterate-trees max-depth min-depth depth)))) | ||
(recur (+ 2 depth) more (conj results result))))) | ||
(println (format "long lived tree of depth %d\t check: %d" max-depth (item-check long-lived-tree)))))) | ||
|
||
(defn -main [& args] | ||
(let [n (if (first args) (Long/parseLong (first args)) 0) | ||
max-depth (if (> (+ min-depth 2) n) (+ min-depth 2) n)] | ||
(main max-depth) | ||
(shutdown-agents))) |
19 changes: 19 additions & 0 deletions
19
2017-mar-31-benchmarks-game-site-versions/fannkuchredux-notes.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
notes, command-line, and program output | ||
NOTES: | ||
64-bit Ubuntu quad core | ||
Clojure 1.8.0 | ||
java version "1.8.0_45" | ||
Java(TM) SE Runtime Environment (build 1.8.0_45-b14) | ||
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode) | ||
|
||
|
||
Sat, 27 Feb 2016 17:35:50 GMT | ||
|
||
MAKE: | ||
mv fannkuchredux.clojure-3.clojure fannkuchredux.clj | ||
/usr/local/src/jdk1.8.0_45/bin/java -Dclojure.compiler.direct-linking=true -Dclojure.compile.path=. -cp .:/usr/local/src/clojure/clojure-1.8.0.jar clojure.lang.Compile fannkuchredux | ||
Compiling fannkuchredux to . | ||
1.25s to complete and log all make actions | ||
|
||
COMMAND LINE: | ||
/usr/local/src/jdk1.8.0_45/bin/java -server -XX:+TieredCompilation -XX:+AggressiveOpts -Xmx16m -cp .:/usr/local/src/clojure/clojure-1.8.0.jar fannkuchredux 12 |
171 changes: 171 additions & 0 deletions
171
2017-mar-31-benchmarks-game-site-versions/fannkuchredux.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
;; The Computer Language Benchmarks Game | ||
;; http://benchmarksgame.alioth.debian.org/ | ||
;; | ||
;; contributed by Alex Miller, ported from Java version | ||
|
||
(ns fannkuchredux | ||
(:require clojure.string) | ||
(:import [java.util.concurrent.atomic AtomicInteger]) | ||
(:gen-class)) | ||
|
||
(set! *warn-on-reflection* true) | ||
(set! *unchecked-math* true) | ||
|
||
(def ^:const NCHUNKS 150) | ||
(def ^AtomicInteger task-id (AtomicInteger.)) | ||
|
||
(definterface Task | ||
(taskLoop [^long n]) | ||
(runTask [^long task ^long n ^longs p ^longs pp ^longs counts]) | ||
(firstPermutation [^long idx ^longs p ^longs pp ^longs counts]) | ||
(^long countFlips [^longs p ^longs pp]) | ||
(nextPermutation [^longs p ^longs counts])) | ||
|
||
(deftype FannTask [^longs fact ;; constant | ||
^long chunksz ;; constant | ||
^long ntasks ;; constant | ||
^longs max-flips ;; global scope | ||
^longs chk-sums ;; global scope | ||
] | ||
Task | ||
(taskLoop [this n] | ||
(let [p (long-array n) | ||
pp (long-array n) | ||
counts (long-array n)] | ||
(loop [] | ||
(let [task (.getAndIncrement task-id)] | ||
(when (< task ntasks) | ||
(.runTask this task n p pp counts) | ||
(recur)))))) | ||
|
||
(runTask [this task n p pp counts] | ||
(let [^longs max-flips max-flips | ||
^longs chk-sums chk-sums | ||
idx-min (* task chunksz) | ||
idx-max (min (aget fact n) (+ idx-min chunksz))] | ||
(.firstPermutation this idx-min p pp counts) | ||
(loop [mflips 1 | ||
chksum 0 | ||
i idx-min] | ||
(if (zero? (aget p 0)) | ||
(let [new-mflips mflips | ||
new-chksum chksum | ||
new-i (inc i)] | ||
(if (< new-i idx-max) | ||
(do | ||
(.nextPermutation this p counts) | ||
(recur new-mflips new-chksum new-i)) | ||
(do | ||
(aset max-flips task new-mflips) | ||
(aset chk-sums task new-chksum) | ||
nil))) | ||
(let [flips (.countFlips this p pp) | ||
new-mflips (max mflips flips) | ||
new-chksum (+ chksum (if (zero? (rem i 2)) flips (- flips))) | ||
new-i (inc i)] | ||
(if (< new-i idx-max) | ||
(do | ||
(.nextPermutation this p counts) | ||
(recur (long new-mflips) (long new-chksum) new-i)) | ||
(do | ||
(aset max-flips task new-mflips) | ||
(aset chk-sums task new-chksum) | ||
nil))))))) | ||
|
||
(firstPermutation [_ idx p pp counts] | ||
(let [^longs fact fact | ||
pl (alength p)] | ||
(loop [i 0] | ||
(when (< i pl) | ||
(aset p i i) | ||
(recur (inc i)))) | ||
(loop [i (dec (alength counts)) | ||
idx idx] | ||
(when (> i 0) | ||
(let [fact-i (aget fact i) | ||
d (quot idx fact-i)] | ||
(aset counts i d) | ||
(System/arraycopy p 0 pp 0 (inc i)) | ||
(loop [j 0] | ||
(if (<= j i) | ||
(let [jd (+ j d) | ||
val (if (<= jd i) | ||
(aget pp jd) | ||
(aget pp (- jd i 1)))] | ||
(aset p j val) | ||
(recur (inc j))))) | ||
(recur (dec i) (long (rem idx fact-i)))))))) | ||
|
||
(nextPermutation [_ p counts] | ||
(let [f (aget p 1)] | ||
(aset p 1 (aget p 0)) | ||
(aset p 0 f) | ||
(loop [i 1 | ||
f f] | ||
(let [ci (inc (aget counts i))] | ||
(aset counts i ci) | ||
(when (> ci i) | ||
(aset counts i 0) | ||
(let [new-i (inc i) | ||
next (aget p 1)] | ||
(aset p 0 next) | ||
(loop [j 1] | ||
(when (< j new-i) | ||
(let [j+1 (inc j)] | ||
(aset p j (aget p j+1)) | ||
(recur j+1)))) | ||
(aset p new-i f) | ||
(recur new-i next))))))) | ||
|
||
(countFlips [_ p pp] | ||
(let [flips 1 | ||
f (aget p 0)] | ||
(if (zero? (aget p f)) | ||
1 | ||
(do | ||
(System/arraycopy p 0 pp 0 (alength pp)) | ||
(loop [f f | ||
flips flips] | ||
(let [new-flips (inc flips)] | ||
(loop [lo 1 | ||
hi (dec f)] | ||
(when (< lo hi) | ||
(let [t (aget pp lo)] | ||
(aset pp lo (aget pp hi)) | ||
(aset pp hi t) | ||
(recur (inc lo) (dec hi))))) | ||
(let [t (aget pp f)] | ||
(aset pp f f) | ||
(if (zero? (aget pp t)) | ||
new-flips | ||
(recur t new-flips)))))))))) | ||
|
||
(defn print-result [n res chk] | ||
(printf "%d\nPfannkuchen(%d) = %d\n" chk n res)) | ||
|
||
(defn fannkuch [^long n] | ||
(let [fact (long-array (concat [1] (reductions * (range 1 (inc n))))) | ||
chunksz (quot (+ (aget fact n) NCHUNKS -1) NCHUNKS) | ||
ntasks (quot (+ (aget fact n) chunksz -1) chunksz) | ||
max-flips (long-array ntasks) | ||
chk-sums (long-array ntasks) | ||
nthreads (.availableProcessors (Runtime/getRuntime)) | ||
tasks (repeatedly nthreads #(->FannTask fact chunksz ntasks max-flips chk-sums)) | ||
threads (into-array Thread (doall (map #(Thread. (fn [] (.taskLoop ^Task % n))) tasks)))] | ||
|
||
(doseq [^Thread t threads] | ||
(.start t)) | ||
|
||
(doseq [^Thread t threads] | ||
(.join t)) | ||
|
||
(print-result n (apply max max-flips) (reduce + chk-sums)))) | ||
|
||
(defn -main [& args] | ||
(let [n (if (seq args) (Long/parseLong (first args)) 12)] | ||
(cond (< n 0) (print-result n -1 -1) | ||
(> n 12) (print-result n -1 -1) | ||
(<= n 1) (print-result n 0 0) | ||
:else (fannkuch n))) | ||
(flush) | ||
(. System (exit 0))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
notes, command-line, and program output | ||
NOTES: | ||
64-bit Ubuntu quad core | ||
Clojure 1.8.0 | ||
java version "1.8.0_45" | ||
Java(TM) SE Runtime Environment (build 1.8.0_45-b14) | ||
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode) | ||
|
||
|
||
Sat, 27 Feb 2016 17:39:14 GMT | ||
|
||
MAKE: | ||
mv fasta.clojure-6.clojure fasta.clj | ||
/usr/local/src/jdk1.8.0_45/bin/java -Dclojure.compiler.direct-linking=true -Dclojure.compile.path=. -cp .:/usr/local/src/clojure/clojure-1.8.0.jar clojure.lang.Compile fasta | ||
Compiling fasta to . | ||
1.22s to complete and log all make actions | ||
|
||
COMMAND LINE: | ||
/usr/local/src/jdk1.8.0_45/bin/java -server -XX:+TieredCompilation -XX:+AggressiveOpts -Xmx16m -cp .:/usr/local/src/clojure/clojure-1.8.0.jar fasta 25000000 |
Oops, something went wrong.