Right, the conversion seems to affect the space savings as well.

On Sun, Jan 31, 2016 at 9:51 PM, Henry Rich <[email protected]> wrote:

> When you throw in a floating-point conversion the fraction of time owing
> to copying arguments becomes smaller.
>
> Henry Rich
>
>
> On 1/31/2016 9:38 PM, Jose Mario Quintana wrote:
>
>> "
>> The observed ratio of measurements for the two operations, in both space
>> and time, is pretty close to (3%5) as we would expect from the above.
>> "
>>
>> It makes sense; yet, what I found interesting was that a measure of
>> overall
>> (in)efficiency, the space*time, gain seems different for the two samples:
>>
>>     1.68731e6 3.33377e6 % 664728 1.81216e6
>> 2.53834651 1.83966648
>>
>>
>>
>> On Sun, Jan 31, 2016 at 9:08 PM, Marshall Lochbaum <[email protected]>
>> wrote:
>>
>> It's not surprising at all if you know a little bit about how the verbs
>>> in question work. Dyad (,) creates a new array and copies its arguments
>>> into it. Thus computing (a,b,c) requires the steps:
>>> - Copy b and c into new array t1 (2e6 copy operations)
>>> - Copy a and t1 into new array t2 (3e6 copy operations).
>>>
>>> In contrast, dyad (;) is almost free, since it just creates an array of
>>> pointers to its arguments. Monad (;) computes the length of its result,
>>> allocates an array of that length, and then copies everything in, for a
>>> total of 3e6 copies. Provided we can't resize a to hold all the values
>>> (which would allow us to only copy b and c), this is optimal with J's
>>> array layout.
>>>
>>> The observed ratio of measurements for the two operations, in both space
>>> and time, is pretty close to (3%5) as we would expect from the above.
>>>
>>> Marshall
>>>
>>> On Sun, Jan 31, 2016 at 08:35:01PM -0500, Jose Mario Quintana wrote:
>>>
>>>> That is interesting, I was independently testing the same expression  ;A
>>>>
>>> ;
>>>
>>>> B ; C  vs  A , B , C  with different sample nouns and it seems leaner
>>>> and
>>>> meaner:
>>>>
>>>>     st=. (, */&.:>@:(1 2&{))@:(] ; 7!:2@:] ; 6!:2)
>>>>
>>>>     'A B C'=. i.3 1000000
>>>>
>>>>     111 st&>'A , B , C' ; ';A ; B ; C'
>>>> ┌──────────┬────────┬─────────┬─────────┐
>>>> │A , B , C │50333184│0.0335228│1.68731e6│
>>>> ├──────────┼────────┼─────────┼─────────┤
>>>> │;A ; B ; C│33556608│0.0198092│664728   │
>>>> └──────────┴────────┴─────────┴─────────┘
>>>>
>>>>        (A , B , C) -: i.3000000
>>>> 1
>>>>        (;A ; B ; C) -: i.3000000
>>>> 1
>>>>
>>>> Using your sample nouns it is not as dominant but remains dominant
>>>> nevertheless:
>>>>
>>>>     A=:?~1000000
>>>>     B=:0.1+?~1000000
>>>>     C=:?~1000000
>>>>
>>>>     111 st&>'A , B , C' ; ';A ; B ; C'
>>>> ┌──────────┬────────┬─────────┬─────────┐
>>>> │A , B , C │67110400│0.0496758│3.33377e6│
>>>> ├──────────┼────────┼─────────┼─────────┤
>>>> │;A ; B ; C│50333824│0.0360027│1.81216e6│
>>>> └──────────┴────────┴─────────┴─────────┘
>>>>
>>>>     (A , B , C) -: (;A ; B ; C)
>>>> 1
>>>>
>>>>
>>>>     JVERSION
>>>> Installer: j602a_win.exe
>>>> Engine: j803/2014-10-19-11:11:11
>>>> Library: 6.02.023
>>>>
>>>>
>>>>
>>>> On Sun, Jan 31, 2016 at 7:05 PM, Raul Miller <[email protected]>
>>>>
>>> wrote:
>>>
>>>> Oops, I meant:
>>>>>
>>>>>     timespacex ';a;b;c'
>>>>> 0.012332 5.03338e7
>>>>>     timespacex ';a;b;c'
>>>>> 0.011768 5.03338e7
>>>>>     (;a;b;c)-:a,b,c
>>>>> 1
>>>>>
>>>>> Efficiency characteristics are the same, result (the most important
>>>>> part) is different.
>>>>>
>>>>> --
>>>>> Raul
>>>>>
>>>>> On Sun, Jan 31, 2016 at 7:04 PM, Raul Miller <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> If I define:
>>>>>>     a=:?~1000000
>>>>>>     b=:0.1+?~1000000
>>>>>>     c=:?~1000000
>>>>>>
>>>>>> I get:
>>>>>>     timespacex 'a,b,c'
>>>>>> 0.016585 6.71104e7
>>>>>>     timespacex '>a;b;c'
>>>>>> 0.012863 5.0334e7
>>>>>>     timespacex '>a;b;c'
>>>>>> 0.011867 5.0334e7
>>>>>>     timespacex 'a,b,c'
>>>>>> 0.015703 6.71104e7
>>>>>>
>>>>>> So it looks like >a;b;c is slightly more efficient than a,b,c, but
>>>>>> it's nowhere close to a factor of 2, so I think I'd ignore this issue
>>>>>> in most contexts.
>>>>>>
>>>>>> --
>>>>>> Raul
>>>>>>
>>>>>>
>>>>>> On Sun, Jan 31, 2016 at 5:21 PM, Henry Rich <[email protected]>
>>>>>>
>>>>> wrote:
>>>>>
>>>>>> You have 3 large lists a, b, c (1000000 atoms each).  You want to
>>>>>>>
>>>>>> join
>>>
>>>> them
>>>>>
>>>>>> into one long list.  What is the best way to do this?
>>>>>>>
>>>>>>> Henry Rich
>>>>>>>
>>>>>>>
>>> ----------------------------------------------------------------------
>>>
>>>> For information about J forums see
>>>>>>>
>>>>>> http://www.jsoftware.com/forums.htm
>>>
>>>> ----------------------------------------------------------------------
>>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>>>
>>>>> ----------------------------------------------------------------------
>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>>
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>
>>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to