LPRun7 startup performance
Hello, I'm using LPRun package to run driver unit tests, (it basically executes something like LPRun7.exe "path\to\file.linq"
), I can see that compilation of each of the scripts takes about ~3-4 seconds before actually running it, while in LINQPad they execute instantaneously (<0.1 sec). Is it possible to somehow NGen/Crossgen assemblies that are used by LPRun to speed up the compilation or are there any other steps I can take to make it faster?
Comments
It sounds like the queries are being modified/touched between executions, which would prevent LPRun from caching the compilations.
Given that you're executing multiple scripts, you can improve performance significantly by using Util.Run instead of LPRun. You can call Util.Run from another LINQPad script (which you can call via LPRun), or from a Visual Studio project that references LINQPad.Runtime.dll (or the LINQPad.Runtime NuGet package).
The advantage of Util.Run is that the Roslyn assemblies remain loaded to execute subsequent scripts. Another benefit is that you can get a typed return value back from the query.
Thanks! I switched to
Util.Run
. One more question, how can I get typed result from Util.Run when my query is async? I triedUtil.Run(filePath, QueryResultFormat.Csv).ReturnValue
but for async query it returnsfor script like
For sync query return works as expected.
Also for some reason when I run
await Util.Run(filePath, QueryResultFormat.Csv).ReturnValueAsync
the driver'sGetSchemaAndBuildAssembly
is called two times, but when I call onlyUtil.Run(filePath, QueryResultFormat.Csv)
it is called just once, is it by design? Can I somehow only call driver method once and get a result?The task serialization issue is a bug that will be fixed in the next build.
I cannot reproduce GetSchemaAndBuildAssembly being called twice. Which driver is it?
https://github.com/romfir/OpenApiLINQPadDriver/tree/tests
On this branch GetSchemaAndBuildAssembly will write logs to log.txt on user desktop, while running a single test I can see that logs are doubled. I've noticed that it only happens when I use
QueryExecuter.ReturnValueAsync
orQueryExecuter.ExceptionAsync
on object returned fromQueryCompilation.Run
(https://github.com/romfir/OpenApiLINQPadDriver/blob/b27552bd62e558512f704f548b600ddb0f0d44fa/Tests/OpenApiLINQPadDriverTests/Utils/QueryExecutor.cs#L45C11-L48C68). Is there other way to run a script and get return value or an exception?