Skip to content

Instantly share code, notes, and snippets.

@ooooak
Last active June 16, 2021 16:40
Show Gist options
  • Save ooooak/e38f87f7637d58f506aa2f41d3ad7e2f to your computer and use it in GitHub Desktop.
Save ooooak/e38f87f7637d58f506aa2f41d3ad7e2f to your computer and use it in GitHub Desktop.
(fun downsweep (xPrev Int tree String) Unit
(let [length 10000000)
input (map #(toArray (- % (- 100 50))) '(0 until length))
output (array (- 1 length) :float)
seqtime (standardConfig measure (runningAverage input output))
partime (standardConfig measure (parRunningAverage input output 10000))]
(case xprev
{:node (left right)}
(parallel (downsweep xPrev, left)
(downsweep (+ xPrev left.xPrev) right))))
def downsweep (xPrev int tree string) {
length: 10000000
input: (map #(toArray (- % (- 100 50))) '(0 until length))
output: (array (- 1 length) :float)
seqtime: (standardConfig measure (runningAverage input output))
partime: (standardConfig measure (parRunningAverage input output 10000))
case xprev {
{:node (left right)} (parallel
(downsweep xPrev, left)
(downsweep (+ xPrev left.xPrev) right))
:else
}
}
(def downsweep (xPrev int tree string)
(let
length 10000000
input (map #(toArray (- % (- 100 50))) '(0 until length))
output (array (- 1 length) :float)
seqtime (standardConfig measure (runningAverage input output))
partime (standardConfig measure (parRunningAverage input output 10000))
(case xprev
{:node (left right)} (parallel (downsweep xPrev, left) (downsweep (+ xPrev left.xPrev) right))
:else none))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment