Win32::API::Prototype and Win32::API::Import effectively do the same thing. They both export a sub into the callers name space that does:

sub ApiName { return $globalHash{ 'ApiName' }->Call( @_ ); }

The name of the global hash is different between the two packages, but the performance should be close to identical.

You will get a minor performance gain by avoiding the import sub. Ie:

usw Win32::API; my $api = Win32::API->new( 'dll', 'api', 'II', 'I' ) or die $^E; $api->Call( @_ );

You avoid an extra level of perl subroutine call and a hash lookup. For all but the lowest cost APIs, the difference will be minimal, as most of the cost is in converting the call parameters to their C equivalents before calling into the DLL. It might make some perceptible difference for calls that take no perameters.

If performance is a realistic consideration, you'd be better off writing Inline::C wrappers for the APIs you need.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: Performance diffrence in using Win32::API:: Import and win32::API::Prototype by BrowserUk
in thread Performance diffrence in using Win32::API:: Import and win32::API::Prototype by manojghosh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.