[Jprogramming] A surprise (to me)
'Michael Day' via Programming
programming at jsoftware.com
Wed Jan 15 10:05:41 UTC 2020
Yes, I get similar timings in J602, J807 and J901 under Windows 10.
I happen to have found that rl performs better (for this example) on the
list of indices
than on the parent string, inadvertently, as I was looking for the
maximum of q!
In JQt 9.01:
Callinjg the long q "ql",
iql =: i.~ q
timex'rl iql'
2.40118
timex'rl ql'
7.50985
while this clunky work in progress gives:
timex'(+/\ inv @: I.@: ~: >:@(>./),~}.) iql'
1.24205
(It's almost right: !
10 {.+/\ inv ( I.@: ~: >:@(>./),~}.) iql
0 1 1 1 1 1 3 1 1 1
10 {.rl iql
1 1 1 1 1 1 3 1 1 1
)
Space isn't so good:
ts'(+/\ inv @: I.@: ~: >:@(>./),~}.) iql' NB. time and space
1.32368 1.67773e9
ts'rl iql'
2.42318 6.49995e8
So - why is the elegant rl "worse" for timing than my horrible cobble?
Mike
On 15/01/2020 08:18, bill lam wrote:
> I have no idea, but I got similar results on linux
>
> time space
> j907 : 5.05662 6.49995e8
> j807 : 1.24932 6.49991e8
> j602 : 0.514155 6.03982e8
>
> A bigger surprise is j602 being the fastest, almost 10 times
> faster than j901.
>
> Tue, 14 Jan 2020, Joey K Tuttle написал(а):
>> I was fiddling with patterns in the first 10e9 digits of Pi this evening and was surprised by a timing.
>>
>> Rather than what I was fooling with, I put it into a smaller easily reproduced example, to wit -
>>
>> MBpro-3:JKTststs jkt$ ja
>> JVERSION
>> Engine: j807/j64/darwin
>> Release-e: commercial/2019-11-04T12:57:58
>> Library: 8.07.26
>> Platform: Darwin 64
>> Installer: J807 install
>> InstallPath: /applications/j64-807
>> Contact: www.jsoftware.com
>> 20?.@$ 2
>> 0 1 0 1 1 0 0 1 1 1 0 0 0 0 1 0 0 0 1 0
>> rl
>> [: #;.1~ 1 , 2 ~:/\ ]
>> rl 20?.@$ 2
>> 1 1 1 2 2 3 4 1 3 1 1
>> q=. (50e6 ?.@$ 10){'0123456789'
>> timex 'z=. rl q'
>> 1.720735 649991296
>> hist
>> ~. ,: #/.~
>> hist z
>> 1 3 2 4 5 7 6 8 9
>> 40500537 405764 4048327 40574 4095 35 410 4 1
>> NB. i.e. one run of 9 digits, 4 of length 8 etc.
>> timex 'hist z'
>> 0.295335 536872960
>> exit 0
>>
>> MBpro-3:JKTststs jkt$ jb
>> JVERSION
>> Engine: j901/j64avx2/darwin
>> Release-c: commercial/2020-01-11T12:24:26
>> Library: 9.01.18
>> Platform: Darwin 64
>> Installer: J901 install
>> InstallPath: /applications/j901
>> Contact: www.jsoftware.com
>> q=. (50e6 ?.@$ 10){'0123456789'
>> timex 'z=. rl q'
>> 6.56145 649995392
>> hist z
>> 1 3 2 4 5 7 6 8 9
>> 40500537 405764 4048327 40574 4095 35 410 4 1
>> 6.56145 % 1.720735
>> 3.813167048
>> exit 0
>> MBpro-3:JKTststs jkt$
>>
>> What surprised me was that the run length function rl took more space and about 4 times as long in J9.01 as in J8.07 - most things I try are the other way around.
>>
>> Have others had similar experiences?
>>
>> Does anyone see a reason my run length verb should bog down?
>>
>> - joey
>>
>>
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list