Skip to content

Support for running in-process in the same original thread #2589

Open
@Youssef1313

Description

@Youssef1313

var runThread = new Thread(() => exitCode = ExecuteCore(host, executeParameters));

Currently, benchmarks always run on background thread. It would be great if a new Toolchain and Executor are run on the same thread, or a property is added to existing toolchains/executors to control whether a background thread is created or not.

Activity

moritz-mg

moritz-mg commented on Jul 16, 2024

@moritz-mg

Actually, just came across this today - we need to benchmark with a native database ORM (Realm), which requires that its instance is created on the same thread that runs the code.
This fails with benchmarkdotnet as-is right now.

timcassell

timcassell commented on Jul 16, 2024

@timcassell
Collaborator

Actually, just came across this today - we need to benchmark with a native database ORM (Realm), which requires that its instance is created on the same thread that runs the code. This fails with benchmarkdotnet as-is right now.

Can't you just set it up in [GlobalSetup] (and tear it down in [GlobalCleanup])?

adamsitnik

adamsitnik commented on Jul 18, 2024

@adamsitnik
Member

This fails with benchmarkdotnet as-is right now.

With the default toolchain no threads are being created and every benchmark is executed in a dedicated, standalone process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @adamsitnik@Youssef1313@timcassell@moritz-mg

        Issue actions

          Support for running in-process in the same original thread · Issue #2589 · dotnet/BenchmarkDotNet