Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Forcing NET to Precompile EXE

Forcing NET to Precompile EXE

Scheduled Pinned Locked Moved C#
performancequestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    redfish34
    wrote on last edited by
    #1

    My understanding is that when you run an EXE, it gets compiled by NET in chunks as you use various parts of the application. This method of execution has advantages for some types of computing. But i have the NEED for SPEEED! This app needs to respond quickly to user interaction at all times as if it was already compiled. My app runs great once it is fully compiled, but is unacceptably slow until it gets to this fully compiled state. Is there a way to instruct NET to precompile your EXE so that it runs at 100% speed from the start? If this causes the application loading to take longer, i accept this tradeoff as the app will start when the computer starts and i do not anticipate the user interacting with the app during this time.

    S L L 3 Replies Last reply
    0
    • R redfish34

      My understanding is that when you run an EXE, it gets compiled by NET in chunks as you use various parts of the application. This method of execution has advantages for some types of computing. But i have the NEED for SPEEED! This app needs to respond quickly to user interaction at all times as if it was already compiled. My app runs great once it is fully compiled, but is unacceptably slow until it gets to this fully compiled state. Is there a way to instruct NET to precompile your EXE so that it runs at 100% speed from the start? If this causes the application loading to take longer, i accept this tradeoff as the app will start when the computer starts and i do not anticipate the user interacting with the app during this time.

      S Offline
      S Offline
      SJ_Phoenix
      wrote on last edited by
      #2

      try ngen.exe (native image generator)...it precompiles an assembly... call it like this: ngen - install NameOfAssembly

      1 Reply Last reply
      0
      • R redfish34

        My understanding is that when you run an EXE, it gets compiled by NET in chunks as you use various parts of the application. This method of execution has advantages for some types of computing. But i have the NEED for SPEEED! This app needs to respond quickly to user interaction at all times as if it was already compiled. My app runs great once it is fully compiled, but is unacceptably slow until it gets to this fully compiled state. Is there a way to instruct NET to precompile your EXE so that it runs at 100% speed from the start? If this causes the application loading to take longer, i accept this tradeoff as the app will start when the computer starts and i do not anticipate the user interacting with the app during this time.

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #3

        redfish34 wrote:

        My app runs great once it is fully compiled, but is unacceptably slow until it gets to this fully compiled state.

        There are various stages you are not considering, beside JIT compilation. - initialization of static data - initialaztion of instances - CPU cache To get everything precompiled (JIT'ed), use ngen on your assembly. I doubt that that will make as much difference as you hope for. Static data is by far the biggest bottleneck.

        xacc.ide-0.1.3 Milestone release
        Includes full source!

        R 1 Reply Last reply
        0
        • R redfish34

          My understanding is that when you run an EXE, it gets compiled by NET in chunks as you use various parts of the application. This method of execution has advantages for some types of computing. But i have the NEED for SPEEED! This app needs to respond quickly to user interaction at all times as if it was already compiled. My app runs great once it is fully compiled, but is unacceptably slow until it gets to this fully compiled state. Is there a way to instruct NET to precompile your EXE so that it runs at 100% speed from the start? If this causes the application loading to take longer, i accept this tradeoff as the app will start when the computer starts and i do not anticipate the user interacting with the app during this time.

          L Offline
          L Offline
          Le centriste
          wrote on last edited by
          #4

          If you really need perfomance, VC++ should be your choice, not .NET. -------- "I say no to drugs, but they don't listen." - Marilyn Manson

          1 Reply Last reply
          0
          • L leppie

            redfish34 wrote:

            My app runs great once it is fully compiled, but is unacceptably slow until it gets to this fully compiled state.

            There are various stages you are not considering, beside JIT compilation. - initialization of static data - initialaztion of instances - CPU cache To get everything precompiled (JIT'ed), use ngen on your assembly. I doubt that that will make as much difference as you hope for. Static data is by far the biggest bottleneck.

            xacc.ide-0.1.3 Milestone release
            Includes full source!

            R Offline
            R Offline
            redfish34
            wrote on last edited by
            #5

            leppie, thanks for your advice. I precompiled my exe using Ngen.exe and no performance gain was observed. It makes sense since most of the assemblies used by my app are already precompiled NET assemblies. So i add Ngen.exe to my long book of Microsoft urban legends (myths). I then tried a hack. I attempted to force precaching of forms by automating user interaction off-screen. I click buttons and cause forms to appear so they get cached. After this is done, the precached forms are presented to the user. Requires some dancing in the WndProc with custom messages. You need to wait until after the paint event to get the cached form. This works as long as the form is mostly visible on screen. When form is mostly offscreen, it does not work. This was a hopeful hack, but it came to a dead end. So after a long trip i have concluded that C# and all the NET languages, is not significantly different than VB6 in GUI performance. This is a disappointment. Luckily i used mostly Win32 calls in my app and not NET equivalents and so porting to C++ will not be to much of a problem.

            L 1 Reply Last reply
            0
            • R redfish34

              leppie, thanks for your advice. I precompiled my exe using Ngen.exe and no performance gain was observed. It makes sense since most of the assemblies used by my app are already precompiled NET assemblies. So i add Ngen.exe to my long book of Microsoft urban legends (myths). I then tried a hack. I attempted to force precaching of forms by automating user interaction off-screen. I click buttons and cause forms to appear so they get cached. After this is done, the precached forms are presented to the user. Requires some dancing in the WndProc with custom messages. You need to wait until after the paint event to get the cached form. This works as long as the form is mostly visible on screen. When form is mostly offscreen, it does not work. This was a hopeful hack, but it came to a dead end. So after a long trip i have concluded that C# and all the NET languages, is not significantly different than VB6 in GUI performance. This is a disappointment. Luckily i used mostly Win32 calls in my app and not NET equivalents and so porting to C++ will not be to much of a problem.

              L Offline
              L Offline
              leppie
              wrote on last edited by
              #6

              redfish34 wrote:

              So after a long trip i have concluded that C# and all the NET languages, is not significantly different than VB6 in GUI performance. This is a disappointment.

              This not true.

              xacc.ide-0.1.3 Milestone release
              Includes full source!

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups