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

Reply via email to