With arguments that small, most of the time is spent in lexing and
parsing. To test the time of execution, you need arguments long enough
that the execution dominates. Or, you can make a tacit verb that has
done the parsing in advance.
To get serious measurements you need to delay the sampling until the
process has been CPU-bound long enough for the OS to change its
scheduling mode from interactive to batch.
Henry Rich
On 8/17/2020 10:45 AM, 'robert therriault' via Programming wrote:
Thanks Henry,
I woke up this morning realizing that the argument to & could be any value and
that cleared up a lot of my fuzziness on what was going on. Thank you to Pascal as
well for the explanation and Roger for twisting my brain for a few hours.
operand =. 2 2 2 $ 3 2 2 3 2 3 3 2
bitmask =. 2 2 2 $ 1 0 0 1 0 1 1 0
operator =. >:
bitmask 0&(] operator) operand NB. original
4 3
3 4
3 4
4 3
bitmask 10&(] operator) operand NB. 10& same result
4 3
3 4
3 4
4 3
bitmask ' '&(] operator) operand NB. type is not even important - ' '&
works
4 3
3 4
3 4
4 3
For efficiency, I don't see much difference between the two with these
particular values
1000 timespacex ' bitmask 0&(] operator)"0 operand'
1.013e_6 2816
1000 timespacex 'bitmask (operator@]^:[)"0 operand'
9.38e_7 2816
But the much simpler addition of the bitmask to the operand is 3 times faster
and takes up half the space.
1000 timespacex 'bitmask + operand'
3.14e_7 1408
bitmask + operand
4 2
2 4
2 4
4 2
Cheers, bob
On Aug 17, 2020, at 07:20, Henry Rich <henryhr...@gmail.com> wrote:
In the example above, the 0& could be any value and is used only as a way of
getting the power function.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
This email has been checked for viruses by AVG.
https://www.avg.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm