Jeremy White wrote:
Just done some performance testing with this type map:

   if(SvROK($arg)) {
       SV** out=hv_fetch((HV*)SvRV($arg), \"-handle\", 7, 0);
       if(out != NULL)
           $var = ($type) SvIV(*out);
       else
           $var = NULL;
   } else
       $var = ($type) SvIV($arg);

Benchmark: timing 1000000 iterations of NewTypeMap, OldTypeMap...
NewTypeMap: 29 wallclock secs (29.64 usr + 0.06 sys = 29.70 CPU) @ 33666.63/s (
n=1000000)
OldTypeMap: 38 wallclock secs (38.22 usr + 0.02 sys = 38.23 CPU) @ 26154.05/s (
n=1000000)

Thoughts?

I'm no typemap expert, but don't see anything wrong with that. Indeed, only doing the hv_fetch once seems like an obvious improvement. If you can hold onto the code until after the next release, then we can get it into CVS for the following release?

No problem - there may be one issue. This code was compiled via Mingw, and as I'm declaring SV** out within a block of code, VC will complain. This may have been the reason that two hash reads were needed. I've a copy of VC now, so once the current build is out of the way, I'll do more testing.

Cheers,

jez.



Reply via email to