Home All Groups Group Topic Archive Search About
Author
13 Apr 2005 1:38 PM
Shane Story
My colleague was trying to do performance testing on function calls in
assembly verses calls to external assemblies (dll's). He said, he made a
function in VB.NET inside of a DLL project, and compiled it.
The function does nothing, and returns a boolean. He opened a separated
Windows Forms project, referenced the DLL project and create the same simple
function as a private function in the winforms project.  Then he called each
of them several times to test time of execution.

He was surprised that the call to the DLL was faster than the one to the
local function. I haven't seen the test, but didn't know why this would be.
Of course we aren't talking about a great time difference but it was
puzzling.  Could it be that the DLL gets put in the GAC and the winforms app
doesn't and this would give it some sort of performance gain?

Any thoughts would be appreciated.

Thanks,

Shane

Author
15 Apr 2005 2:01 AM
Patrick Steele [MVP]
In article <O6RD11CQFHA.1***@TK2MSFTNGP10.phx.gbl>, shanesREMOVETHIS@dv-
corp.com says...
> My colleague was trying to do performance testing on function calls in
> assembly verses calls to external assemblies (dll's). He said, he made a
> function in VB.NET inside of a DLL project, and compiled it.
> The function does nothing, and returns a boolean. He opened a separated
> Windows Forms project, referenced the DLL project and create the same simple
> function as a private function in the winforms project.  Then he called each
> of them several times to test time of execution.
>
> He was surprised that the call to the DLL was faster than the one to the
> local function. I haven't seen the test, but didn't know why this would be.
> Of course we aren't talking about a great time difference but it was
> puzzling.  Could it be that the DLL gets put in the GAC and the winforms app
> doesn't and this would give it some sort of performance gain?

Nothing gets put into the GAC unless it's specifically told to.  My
guess would be that the JIT compiler sees that the DLL function contains
no executable code that can change the return value and therefore it
might actually cache the value.  Or maybe calls to the DLL function are
JIT-compiled into an assignment based on the return value.

So if the DLL function was:

public function GetData() as boolean
    return True
end function

Calling the function from the winform as:

    dim data as Boolean = thedll.GetData()

May be compiled at run-time into something like this:

    dim data as Boolean = True

This is all just a guess.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele