// this is a straight port of the Scheme code in array-mult.scm (defn multArrayLoop [a b res i] (cond (== i (len a)) res (begin (aset res i (* (aget a i) (aget b i))) (multArrayLoop a b res (+ i 1))))) (defn multArray [a b] (multArrayLoop a b (makeArray (len a)) 0)) (defn randomArray [arr i] (cond (== i (len arr)) arr (begin (aset arr i (random)) (randomArray arr (+ i 1))))) (defn doInLoop [fx times] (cond (== times 0) nil (begin (fx) (doInLoop fx (- times 1))))) // (let [ a (randomArray (makeArray 100) 0) b (randomArray (makeArray 100) 0) ] (doInLoop (fn [] (multArray a b)) 200)) /* on my laptop, about 34x slower than Chez scheme. jaten@jatens-MacBook-Pro ~/go/src/github.com/glycerine/zygomys/benchmarks (master) $ time zygo ./array-mult.zy real 0m4.322s user 0m5.737s sys 0m0.191s jaten@jatens-MacBook-Pro ~/go/src/github.com/glycerine/zygomys/benchmarks (master) $ time scheme --script ./array-mult.scm real 0m0.169s user 0m0.136s sys 0m0.021s $ gi -q gi> = 5.737 / 0.169 33.94674556213 */