3
votes

I'm making an audio application that uses dll plugins that are loaded using the Assembly.LoadFrom(file).GetTypes()... And the Activator.CreateInstance(T).

My question is not if the loading process is slow, the initialization time isn't important, i'm asking if a plugin has an audio procesing loop inside, this will be slower than if i simply add the class directly without using plugins??

3
Do some profiling of a test application both ways and find out for yourself. It's actually fairly simple. - M.Babcock
The IL in the assembly gets translated to machine code by the just-in-time compiler. There is just one kind of machine code, there are no low or fast versions and the jitter doesn't care where the IL came from. - Hans Passant

3 Answers

3
votes

Once the assembly is loaded into memory and has been instantiated using the "Activator.CreateInstance(T)" method, the performance of it should be no different than a direct reference.

2
votes

Once you have loaded the content of the DLL, the performance should be the same as if you were using a direct reference to it. That is because the content of the DLL is going to be loaded into the memory of the current process. So accessing the memory will have the same performance as if directly referenced, and CPU time will be shared as if directly referenced.

Only the initial loading will be considerably slower.

This guy uses the LoadFrom to do some amazing stuff http://www.codeproject.com/Articles/4610/Three-Ways-to-Inject-Your-Code-into-Another-Proces

0
votes

This seems strange...

When the assembly is loaded, there's no difference...

So, I suggest to diagnose on these:

  1. Are the assemblies loaded in the same application domain?
  2. The assemblies you loaded is compiled in debug or release mode?
  3. Check your reflection actions since reflection has negative effects on performance
  4. Check assembly .net runtime version, is the performance problem caused by side by side?

I hope these tips can help you ~