----- Original Message -----
From: "Eric Wilhelm" <[EMAIL PROTECTED]>
To: <inline@perl.org>
Sent: Friday, January 19, 2007 10:23 PM
Subject: Re: Percentiles
# from Sisyphus
# on Friday 19 January 2007 02:39 am:
Well ... I can't detect a significant difference for a 10,000,000
element array of integers.
.
.
That's actually counter to the pure-perl
behavior. I suppose the XS code is basically accessing the array ref
already.
I think so. As I hinted earlier, the true guts of the situation is probably
best accessed by looking at the C code that xsubpp generates. When I run the
script (that I supplied earlier) with the 'CLEAN_AFTER_BUILD => 0' config
option, and subsequently take a look at the generated C file I find, in
part:
------------------------------
#line 41 "arrays_pl_6c1f.c"
XS(XS_main_by_list); /* prototype to pass -Wmissing-prototypes */
XS(XS_main_by_list)
{
dXSARGS;
if (items < 1)
Perl_croak(aTHX_ "Usage: main::by_list(x, ...)");
SP -= items;
{
SV * x = ST(0);
#line 40 "arrays_pl_6c1f.xs"
I32* temp;
#line 54 "arrays_pl_6c1f.c"
#line 42 "arrays_pl_6c1f.xs"
temp = PL_markstack_ptr++;
by_list(x);
if (PL_markstack_ptr != temp) {
/* truly void, because dXSARGS not invoked */
PL_markstack_ptr = temp;
XSRETURN_EMPTY; /* return empty stack */
}
/* must have used dXSARGS; list context implied */
return; /* assume stack size is correct */
#line 65 "arrays_pl_6c1f.c"
PUTBACK;
return;
}
}
XS(XS_main_by_ref); /* prototype to pass -Wmissing-prototypes */
XS(XS_main_by_ref)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: main::by_ref(x)");
SP -= items;
{
AV * x;
#line 56 "arrays_pl_6c1f.xs"
I32* temp;
#line 83 "arrays_pl_6c1f.c"
if (SvROK(ST(0)) && SvTYPE(SvRV(ST(0)))==SVt_PVAV)
x = (AV*)SvRV(ST(0));
else
Perl_croak(aTHX_ "x is not an array reference");
#line 58 "arrays_pl_6c1f.xs"
temp = PL_markstack_ptr++;
by_ref(x);
if (PL_markstack_ptr != temp) {
/* truly void, because dXSARGS not invoked */
PL_markstack_ptr = temp;
XSRETURN_EMPTY; /* return empty stack */
}
/* must have used dXSARGS; list context implied */
return; /* assume stack size is correct */
#line 99 "arrays_pl_6c1f.c"
PUTBACK;
return;
}
}
--------------------------
Eric, you're probably more capable of assessing the difference (if there is
an essential difference between the two functions) than I am ... but it
seems to me that they are basically the same.
Disclaimer: I'm now even more innebriated than I was when I first provided a
reply to this thread :-)
Cheers,
Rob