The performance inpact of unboxing in J may cause a misconception.
If fact, unlike Java and C#, which create copy of value on
unboxing, in J unboxing is very efficient. Sometimes even
considerably more efficient than using equivalent open flat arrays.

It can be shown using symbol introspection that when returning
unboxed data J does not create a copy, but instead operates directly
on the underlying values. But here we will use indirect examples to
show raw perfomance comparison.

First, unboxing itself does not create any time or space increase.

   10{. A=: 1e6$'abc'
abcabcabca
   B=: <A
   ts '+/@(a.&i.)    A'
0.03333 4.19802e6
   ts '+/@(a.&i.)   >B'
0.032933 4.19802e6
  ts '+/@(a.&i.) |.>B'    NB. unless unboxed value is modified
0.058845 5.24659e6

Next we will show how using boxed data dramatically 
improves both time and especially space performance
as compared to similar flat arrays.

   2 4{.A=: 100 100$'abc'
abca
bcab
   B=: <"1 A
   ts '([EMAIL PROTECTED] ([: +/@(a.&i.)   {)"0 _ ]) A'
0.000453939 23296
   ts '([EMAIL PROTECTED] ([: +/@(a.&i.) >@{)"0 _ ]) B'
0.000411968 7360

This special advantage of boxed representation
opens up some interesting possibilities, such as Inverted Tables,

   http://www.jsoftware.com/jwiki/Essays/Inverted_Table


--- Roger Hui <[EMAIL PROTECTED]> wrote:

> I was having a similar discussion with my
> colleague Seth Breidbart.  I said, "Save a 
> microsecond here and a microsecond there and
> pretty soon --" 
> "-- you'd have a millisecond," Seth cut in.
> 
> 
> 
> ----- Original Message -----
> From: Devon McCormick <[EMAIL PROTECTED]>
> Date: Saturday, May 19, 2007 7:38 pm
> Subject: Re: [Jprogramming] Why is ARGV boxed if the list is homogeneous?
> 
> > How much time does this waste?
> > 
> > It _saves_ time when I don't have to re-invent command-line 
> > parsing, e.g.
> > 
> > >jconsole.exe "An argument with embedded blanks"
> > 
> >    1{ARGV_j_
> > +--------------------------------+
> > |An argument with embedded blanks|
> > +--------------------------------+
> > 
> > 
> > On 5/19/07, Terrence Brannon <[EMAIL PROTECTED]> wrote:
> > >
> > > It seems that boxed args must be unboxed before use, wasting time.
> > > Further, since a J program can only have strings in ARGV, what 
> > is the
> > > point?
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 



 
____________________________________________________________________________________
TV dinner still cooling? 
Check out "Tonight's Picks" on Yahoo! TV.
http://tv.yahoo.com/
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to