It looks like the sentence Dan uses depends on the name D. I get your
results if D is undefined.
With D defined as 1 million ints, I get results similar to Dan's.
I also have a slightly faster version:
(32 b.~ 1&(17 b.))
Henry Rich
On 1/4/2016 8:17 PM, David Lambert wrote:
Time and space results vary wildly.
JVERSION
Engine: j803/2014-10-19-11:11:11
Library: 8.04.14
Platform: Linux 64
Installer: unknown
InstallPath: /usr/share/j/8.0.4
boxdraw_j_ 1
(;:'Verb TimeX SpaceX') , V ,. '0.2' 8!:0 (%"1 <./) Q=:100
timespacex&> ' D' ,L:0~ V=: '+:^:(2&|)"0';']`+:@.(2&|)"0';'(* 1+2&|)'
+-------------+-----+------+
|Verb |TimeX|SpaceX|
+-------------+-----+------+
|+:^:(2&|)"0 |1.14 |1.09 |
+-------------+-----+------+
|]`+:@.(2&|)"0|1.57 |1.35 |
+-------------+-----+------+
|(* 1+2&|) |1.00 |1.00 |
+-------------+-----+------+
On 01/04/2016 07:51 PM, [email protected] wrote:
Date: Mon, 4 Jan 2016 12:13:47 -0500
From: Dan Bron<[email protected]>
To: J Programming<[email protected]>
Subject: Re: [Jprogramming] a performance quirk
Message-ID:<[email protected]>
Content-Type: text/plain; charset=utf-8
Performance analysis requires a kind of triage. The first thing that
sticks out about both expressions is that ?0 . We need to excise
that first: J is a language that expects and rewards thinking big.
(;:'Verb TimeX SpaceX') , V ,. '0.2' 8!:0 (%"1 <./) Q=:100
timespacex&> ' D' ,L:0~ V=: '+:^:(2&|)"0';']`+:@.(2&|)"0';'(* 1+2&|)'
+-------------+-----+------+
|Verb |TimeX|SpaceX|
+-------------+-----+------+
|+:^:(2&|)"0 |34.71| 1.00 |
+-------------+-----+------+
|]`+:@.(2&|)"0| 3.70| 5.75 |
+-------------+-----+------+
|(* 1+2&|) | 1.00| 2.00 |
+-------------+-----+???+
Having said that, the ~35x slowdown (vs ~4x for @.) is more than a
little surprising. The very specific 2x space improvement over the
array solution is likely telling us something about what?s going on,
but I haven?t quite thought through what it is yet.
-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm