glycerine/zygomys

benchmarks/array-mult.zy, seems outdated

jkleiser opened this issue · 1 comments

I was trying to run this benchmark code https://github.com/glycerine/zygomys/blob/master/benchmarks/array-mult.zy, but it seems to be old and outdated. I tried to fix it, like this:

(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 [func times]
  (cond (== times 0) %()
    (begin
      (func)
      (doInLoop func (- times 1)))))

(timeit (fn [] (let [a (randomArray (makeArray 1000) 0)    
      b (randomArray (makeArray 1000) 0)]
  (doInLoop (fn [] (multArray a b)) 1000))))

but it still has a prblem. I get this:

error in func:-1: Error calling 'timeit': Error calling 'func': missing arguments. use: (func funcName [inputs:type ...] [returns:type ...])
in doInLoop:11
in __anon266:15
in timeit:-1
in __main:25

How can this be fixed?

func is a reserved word. The fix is to rename that parameter to fxor something else. I'll push an update.