tags:

views:

38

answers:

2

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 - startTime

I 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.

+1  A: 

It should be like that (just guessing, Operating Systems Course is some time ago)

  1. Mapping into Memory
  2. Loading linked shared libraries (DLLs) and their linked shared libraries
  3. Process Creation
  4. Instantiation/Creation of static objects and other things before main-Function
  5. [maybe loading Ressources, do not know if Windows id doing that]
  6. C/C++-Library-Methods before main-Funktion
  7. starting main-Function.

4 and 6 may come together.

nob
It's worth mentioning that Windows doesn't load the entire executable file into memory at once, but demand-pages as necessary. This isn't obvious if you're unfamiliar with memory mapping :)
snemarch
A: 

Application might be small, but it is possible that it is referencing a lot of libraries.

  1. reading from drive
  2. writing to memory
  3. loading dlls and related file (reading from drive)
  4. writing to memory
  5. 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
Alex