Steps involved in the running of an exe
Question:
When we run an exe(assume by double clicking), where all the time is spent before it actually starts executing ?
a) Loading of the exe onto the memory
b) ? c) ?Background of the question:
I am profiling the execution of an application(App.exe) and trying to improve its performance. I have a test that does something like:
startTime = beginTimer()
"start App.exe" "wait till a window becomes responsive" - App.exe executes during this time and launches a window endTime = endTimer() outputValue =开发者_运维技巧 endTime - startTimeI have added time stamps at different places in App.exe to obtain the execution time spent at different phases and also to obtain the total execution time of App.exe.
I notice that "outputValue" is around 5 secs, where as the total time spent in the execution of App.exe(obtained from time stamps in the exe) is around 2 secs.
It seems to me that around 3 secs was already spent before App.exe even actually started executing. The size of the exe is around 2700 KB.
It should be like that (just guessing, Operating Systems Course is some time ago)
- Mapping into Memory
- Loading linked shared libraries (DLLs) and their linked shared libraries
- Process Creation
- Instantiation/Creation of static objects and other things before main-Function
- [maybe loading Ressources, do not know if Windows id doing that]
- C/C++-Library-Methods before main-Funktion
- starting main-Function.
4 and 6 may come together.
Application might be small, but it is possible that it is referencing a lot of libraries.
- reading from drive
- writing to memory
- loading dlls and related file (reading from drive)
- writing to memory
- creates process and executes program logic
Things you can do to improve it:
- in the start up program, remove all includes that are not used
- make sure program is compiled without debug information. In Visual Studio it is "Release" and not "Debug". Will improve performance and decrease executable size
- if project reads database and/or file on start-up, most likely this is where the problem is
- this is a .NET application, make sure it runs on latest .NET Framework
精彩评论