You might try timings on sub-expressions to find where the speed differences occur?
Thanks, -- Raul On Wed, Aug 6, 2014 at 1:27 PM, 'Pascal Jasmin' via Programming <[email protected]> wrote: > BASE64=: (a.{~ ,(a.i.'Aa') +/i.26),'0123456789+/' > > tobase64=: 3 : 0 > res=. BASE64 {~ #. _6 [\ , (8#2) #: a. i. y > res, (0 2 1 i. 3 | # y) # '=' > ) > > tob64 =: ('=' #~ 0 2 1 i. 3 | # ) ,~ BASE64 {~ [: #. _6 ]\ (8#2) ,@:#: > a.&i. > tb64 =: 3 : '(''='' #~ 0 2 1 i. 3 | # y) ,~ BASE64 {~ #. _6 ]\ (8#2) > ,@:#: a.&i. y' > > frombase64=: 3 : 0 > pad=. _2 >. (y i. '=') - #y > pad }. a. {~ #. _8 [\ , (6#2) #: BASE64 i. y > ) > fb64 =:a. {~ [: #. _8 [\ (6#2) ,@:#: BASE64&i. }.~ _2 >. # -~ i.&'=' > > tobase64 is original code from addon. It is explicit with a temporary > variable. tb64 is also explicit but without the temp var. tob64 is a tacit > version. > > a =. 100000 $ a. > > timespacex 'tob64 a' > > 0.0312112 1.78275e7 > timespacex 'tobase64 a' > 0.0277369 2.85809e7 > timespacex 'tb64 a' > 0.0289411 2.04608e7 > > all are impressively fast, but the 2 explicit functions are faster, and > somehow the one with a temp variable is fastest. > > the tacit version does use less space, as well as the one line tacit entry. > Its also faster for array item application > > > timespacex 'tob64"1 ] 100 1000 $ a' > 0.0154246 539264 > timespacex 'tobase64"1 ] 100 1000 $ a' > 0.016376 628736 > > Its also surprising though that applying the function to 100 smaller items is > faster than the whole. > > > Any insights on why this is happening? > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
