void
CxtSpeed()
PREINIT:
LARGE_INTEGER start;
LARGE_INTEGER end;
int i;
PPCODE:
QueryPerformanceCounter(&start);
for(i=0; i < 1000000000; i++){
no_cxt();
}
QueryPerformanceCounter(&end);
printf("no cxt %I64u\n", end.QuadPart-start.QuadPart);
QueryPerformanceCounter(&start);
for(i=0; i < 1000000000; i++){
cxt(aTHX);
}
QueryPerformanceCounter(&end);
printf("cxt %I64u\n", end.QuadPart-start.QuadPart);
####
//separate compiland/obj file
#define PERL_NO_GET_CONTEXT
#include
#include
#include
__declspec(dllexport) int no_cxt(){
dTHX;
return ((int) my_perl) >> 1;
}
__declspec(dllexport) int cxt(pTHX){
return ((int) my_perl) >> 1;
}
####
#in makefile.pl hash to WriteMakefile
FUNCLIST => ['no_cxt', 'cxt'],
dynamic_lib => { OTHERLDFLAGS => ' noopt.obj ' ,
INST_DYNAMIC_DEP => 'noopt.obj'
},
####
C:\Documents and Settings\Owner\Desktop\cpan libs\lxs>perl -MLocal::XS -e "Local::
XS::CxtSpeed();"
no cxt 48160819
cxt 11096124
C:\Documents and Settings\Owner\Desktop\cpan libs\lxs>