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.
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |