>-----Original Message-----
>From: IBM Mainframe Discussion List [mailto:[email protected]] On
>Behalf Of David Crayford
>Sent: Thursday, October 23, 2014 10:08 PM
>To: [email protected]
>Subject: Re: [ANN] Lua4z: the Lua programming language on z/OS, with batteries>
>
>
<snip>
>OK, let's try simple matrix multiplication which should test both array
>access and math.
>
>/* REXX */
>arg count
>if count = "" then count = 1000000
>start = sysvar("SYSCPU")
>do i = 1 to count
> a.i = i * i
>end
>say 'CPU time = 'sysvar("SYSCPU") - start
>
>CPU time = 3.57
>
>local t = require("timer")()
>local count = arg[1] or 1000000
>local a = {}
>for i = 1, count do a[i] = a[i] * i end
>t:print_elapsed()
>
>elapsed time: 0.131965
>
>
>That's a huge difference, two orders of magnitude.
>
<snip remainder>
Maybe I'm just showing my ignorance of the Lua language syntax,
but this statement:
" a[i] = a[i] * i "
Does not appear to be the equivalent to the REXX statement:
" a.i = i * i "
In fact, I would expect that the above Lua statement is actually multiplying i
by an uninitialized variable "a[i]". Assuming the above code executes without
error, then due to the principle of least astonishment, I would imagine that
this uninitialized value is assumed to be zero.
If that IS what is happening, it will of course be MUCH faster to compute i * 0
than to compute i squared.
Can someone with Lua syntax knowledge please enlighten me?
Thanks,
Bill Bass
United HealthCare / Optum
This e-mail, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity
to which it is addressed. If the reader of this e-mail is not the intended
recipient or his or her authorized agent, the reader is hereby notified
that any dissemination, distribution or copying of this e-mail is
prohibited. If you have received this e-mail in error, please notify the
sender by replying to this message and delete this e-mail immediately.
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN