Poor LpRun startup performance for simple script

When I have LinqPad up and running new scripts I write compile and execute nearly instantaneously.

However, when running on the command line via LpRun there is quite a long delay even for a trival script (~3-4 seconds).

I'm thinking of working around this by creating an LpRun background process that listens for execution requests and executes them using Util.Run() to avoid the startup overhead.

However, I'm wondering whether others have experienced this performance issue and whether built-in approaches are available for working around this?


  • I also experience the same thing, lprun takes about 4 seconds to return the result of something simple like:

    void Main(string[] args)
    string.Format("{0}", args).Dump();
    so it'd sure be great to find ways to speed it up.

    for some reason, I used to think it was quicker if I had the LINQPad GUI running, but I've just tested and it seems to make no difference now...
  • The release version of LINQPad ngens the Roslyn assemblies on installation. However, if you've xcopy-deployed LINQPad, this won't happen automatically. To do this, follow the instructions in the file "lprun readme.txt":

    Open the administrator command prompt, and call:

    LINQPad.exe -ngen

    Note that this won't work with the current beta, because it includes two (conflicting) sets of Roslyn assemblies - one release set and one experimental set for playing with nullable reference types.
  • edited May 2018
    i'm getting the same thing
    latest version 5.31(AnyCPU)
    ran ngen and saw that it created files

    still about 4 seconds to run anything via commandline, tenths of seconds to run the same script via linqpad
  • Have you waited a few minutes for ngen to complete?
  • I did find some improvements after running linqpad -ngen. I did some timings:

    Before running -ngen, I had a script that actually took a little time to run.

    I use a stopwatch inside linqpad script, as well as in c# code that calls the script and waits for it to finish.

    Script took 1583 milliseconds inside linqpad script.
    Running linqpad script - took 7611 ms.

    I changed to a script that was just a writeline - bad scientist changing two things at once.

    Script took 7 milliseconds inside linqpad script.
    Running linqpad script - took 2723 ms.

    But you can see linqpad overhead went from about 6 seconds to 2.7 seconds.

    This might still be a bit clunky for my intended usage ( writing "macro" type code for automation ). It could probably be resolved with something like caching executables or something, or having a way to generate executables, I don't know.

    Or... hmm... it runs fast in linqpad, so what if linqpad is open, could lprun send a message to the running linqpad instance and tell it to run a filename? Perhaps that could be an command line option on lprun or linqpad.exe.

  • I realized I was testing the latest beta, so I tried with the stock installed one and I got similar results.

    Before -ngen:
    Script took 4 milliseconds inside linqpad.
    AutoStopWatch Running linqpad script - took 5590 ms.

    Script took 4 milliseconds inside linqpad.
    2018-06-07 07:22:57.9062 INFO AutoStopWatch Running linqpad script - took 2740 ms.

    I'm not sure, seems like I had to run ngen again for installed one. Don't know if it is makes a difference having multiple linqpads in multiple locations.

Sign In or Register to comment.