Because (in theory) the explicit code can change dynamically, the interpreter must (and does) re-parse it at every invocation.
So the rule of thumb is "don't apply explicit verbs at low rank". But a bigger, more general rule is "write your verbs to apply at as a high a rank as possible". Or, briefly: "show J the big picture". -Dan -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Pascal Jasmin Sent: Monday, November 04, 2013 8:54 PM To: [email protected] Subject: Re: [Jprogramming] weird syntax error These are almost the same timings. 4.5x speed improvement from tacit. I'm using AMD A8 apu. results were from j632 You are right that I should precalculate the data so as to better compare explicit vs implicit. The focus of the test for me was to see the difference between the convenient explicit unpacking ('a b c' =.) and "manual unpacking" in an implicit expression. The +:,-: are just some dummy work. Though the . approach is impressively fast: 42M triples processed per second! The vocabulary page on . could use a link to a math refresher, and maybe a 2nd pass on the english to english translation. j6-64 ts ,&'/sec '@":@%@(6!:2) , ,&'MB'@":@(%&1000000)@(7!:2)@:] 10 ts '( -:@>@{. + >@(1&{) + +:@>@{:)"1 D' 11.679/sec 1.05472MB 10 ts '(3 : '' ( -: a) + b + (+: c) [ ''''a b c'''' =. y'')"1 D' 2.34412/sec 1.06189MB thinking that this tests the code parsing engine: D5 =. 1e2 3 $ ;/ i.37 1e4 ts '( -:@>@{. + >@(1&{) + +:@>@{:)"1 D5' 10838.7/sec 0.007168MB 1e4 ts '(3 : '' ( -: a) + b + (+: c) [ ''''a b c'''' =. y'')"1 D5' 2071.46/sec 0.014336MB it appears that there is a (slightly) wider performance advantage in parsing tacit vs explicit code. ----- Original Message ----- From: Dan Bron <[email protected]> To: [email protected] Cc: Sent: Monday, November 4, 2013 7:30:50 PM Subject: Re: [Jprogramming] weird syntax error Sorry, I meant to call out specifically, with the second set of timings, that I'd separated the calculations from the separation of the data. That is, including 1e5 3 $ ;/ i.37 in your measurements was hiding some of the differences between the tacit and explicit approaches. -Dan -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Dan Bron Sent: Monday, November 04, 2013 7:25 PM To: [email protected] Subject: Re: [Jprogramming] weird syntax error I can't reproduce your results on my machine. Here's a run on mine: JVERSION Installer: j602a_win64.exe Engine: j602/2008-03-03/16:45 Library: 6.02.023 ts =: [: ;:^:_1 ('/sec';'MB') ,&.>~ ('0';'0.3') 8!:0 %@:(6!:2) , 1e_6 * 7!:2@:] 10 ts '(3 : '' ( -: a) + b + (+: c) [ ''''a b c'''' =. y'')"1 ] 1e5 3 $ ;/ i.37' 1/sec 7.722MB 10 ts '( -:@>@{: + >@(1&{) + +:@>@{:)"1 ] 1e5 3 $ ;/ i.37' 3/sec 7.713MB D=:1e5 3 $ ;/ i.37 10 ts '(3 : '' ( -: a) + b + (+: c) [ ''''a b c'''' =. y'')"1 D' 1/sec 1.062MB 10 ts '( -:@>@{: + >@(1&{) + +:@>@{:)"1 D' 5/sec 1.055MB D2=:1e5 3 $ i.37 NB. Boxes superfluous 10 ts '(3 : '' ( -: a) + b + (+: c) [ ''''a b c'''' =. y'')"1 D2' 1/sec 1.062MB 10 ts '( -:@>@{: + >@(1&{) + +:@>@{:)"1 D2' 4/sec 1.055MB NB. More direct approach 10 ts '0.5 1 2 +/@:*"1 D2' 16/sec 1.053MB 10 ts '0.5 1 2 +/ .* |:D2' 117/sec 9.441MB NB. Define D more naturally for use-case D3=:|:D2 10 ts '0.5 1 2 +/ . * D3' 429/sec 5.246MB -Dan -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Pascal Jasmin Sent: Monday, November 04, 2013 5:04 PM To: [email protected] Subject: Re: [Jprogramming] weird syntax error sorry, I found it right after sending, but here is another stumper also, ts '(3 : '' ( -: a) + b + (+: c) [ ''a b c'' =. y'')"1 ] 1e5 3 $ ;/ i.37' needs to be: ts '(3 : '' ( -: a) + b + (+: c) [ ''''a b c'''' =. y'')"1 ] 1e5 3 $ ;/ i.37' 2.17296/sec 4.3856MB and just fyi, the point of why I was doing that, the equivalent tacit form timing: ts '( -:@>@{: + >@(1&{) + +:@>@{:)"1 ] 1e5 3 $ ;/ i.37' 9.2746/sec 4.38099MB ----- Original Message ----- From: Michael Dykman <[email protected]> To: J Programming <[email protected]> Cc: Sent: Monday, November 4, 2013 4:56:01 PM Subject: Re: [Jprogramming] weird syntax error double your quotes when inside quotes. t =. 3 : ' ( -: a) + b + (+: c) [ ''a b c'' =. y' On Mon, Nov 4, 2013 at 4:53 PM, Pascal Jasmin <[email protected]>wrote: > I'm likely doing something silly, but I just don't see the mistake: > > (-: a)+b++:c [ 'a b c' =. ;/ 1 2 3 > 8.5 > t =. 3 : ' ( -: a) + b + (+: c) [ 'a b c' =. y' > |syntax error > | (-:a) +b+(+:c)[ > > is it trying to form a train with [ as the rh most verb? > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- - michael dykman - [email protected] May the Source be with you. ---------------------------------------------------------------------- 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
