Impact of DLL on execution speed

First of all, I use the custom header and the corresponding cpp file. Then I turn on and so on. If I switched to a DLL, would the code execution speed be delayed?

Secondly, I know that in the "DLL" the "D" represents "dynamic", but my friend said that there are two ways to use them: statically and dynamically. If it is already dynamic, what do we do with "static"?

+6
source share
2 answers

If the function is not very small (therefore, it turns the other way), using a DLL does not have any difference in performance (except that loading a DLL increases the startup time of your application.) Large, critical applications use DLLs (for example, Intel Math library) . There are minor penalties if the compiler cannot optimize the entire program, but these are very small differences that usually do not matter.

Regarding static / dynamic: I assume that it means you can link the DLL in the usual way (using the import library), which forces it to always load or load it dynamically at runtime (using LoadLibrary and dlopen .) There is no difference in performance, but using LoadLibrary allows you to delay loading the library to the actual level.

+12
source
  • Performance should not regress, since a call function from a dll is generally similar to a call to a local function.

  • There are two types of libraries:

    • from one point of view, dynamic libraries and static libraries. Here static means that all the code from lib will be linked statically with your exe , the opposite dynamic lib allows you to separate the code from the executable file to the shared library, this code will be loaded dynamically.
    • Then the dynamic library can be linked statically, which means that the OS will link the library with your program at startup and dynamically, which means that you get pointers to the characters stored in the library by hand. Although dynamic loading provides more flexibility, it is more complicated than using static binding.
+2
source

Source: https://habr.com/ru/post/909407/


All Articles