{⍺+⍵}/ ⍳1000000 is NOT equivalent to: +/ ⍳1000000
Rather:
∇Z←A PLUS B
Z←A + B
∇
and then:
{⍺+⍵}/ ⍳1000000
is equivalent to: FOO/⍳1000000
The 12 seconds are mainly spent for one million calls
of FOO, each call passing two scalar arguments A and B
and returning a scalar Z. It also wraps every Cell (i.e. every
ravel item) of A, B, and Z into a scalar value A, B, and Z.
Ravel cells are rather light-weight while values are more heavy
(each scalar value has, for example, its own shape vector).
And finally: each call of FOO pushes and pops an )SI entry and
a value stack entry for each A, B, and Z. These operations
are pretty fast but become noticeable if you do them very often.
In your example one call of FOO takes 12 micro-seconds which
is, IMHO, not too bad.
You could have avoided this overhead by computing:
{+/ ⍵} ⍳1000000 instead of: {⍺+⍵}/ ⍳1000000
Best Regards,
Jürgen Sauermann