Home

Benchmark stuck on "Waiting for first iteration to complete..."

I have a linq query running against a connected DBContext in a DLL, so the query references that assembly and other assemblies. The query executes correctly and returns the expected data.

When trying to benchmark the query, BenchmarkDotNet launches but just sits on "Waiting for first iteration to complete...". Nothing seems to be happening, nor is LINQPad frozen.

The demo runs fine

try   { throw new InvalidOperationException(); }
catch { }

If I include the same

try   { throw new InvalidOperationException(); }
catch { }

into my script, select that code only and execute, it again just sits on "Waiting for first iteration to complete..."

Is there a log or something I can check to see if something is breaking?

Regards
Adrian

Comments

  • I came across this error message and the reason was because BenchMark DotNet requires a parameterless constructor which is missing for connections using a DBContext in a custom assembly.

    In my case I could solve it by adding my own like

    public UserQuery() :   base (LINQPad.Util.CurrentCxString) {}
    

    See https://forum.linqpad.net/discussion/comment/8382 for a similar issue.

  • edited January 12

    Thanks for the reply.

    I don't think I fully understand what you mean by the above.

    I created a new query (.Net 8 - C# Statements) from my DbContext and added only the above to the query but I just get an error:

    CS1513 } expected

    i also tried by used the DbContext() and DbContext(DbContextOptions) on the connection properties, same error shows?

    Any ideas?

  • Has to be a C# program rather than C# Statements.

    Example.

    #load "BenchmarkDotNet"
    
    public UserQuery() :   base (LINQPad.Util.CurrentCxString) { }
    
    void Main()
    {
        RunBenchmark();
    }
    
    [Benchmark]
    public void Benchmark()   
    {
    
    }
    
    

    This only works because Linqpad creates the class called UserQuery which is derived from my DbContext and that class has a constructor which takes a string.

Sign In or Register to comment.