microsoft / microsoft/testfx

[perf-improver] Add benchmark coverage for ObjectModelConverters.FixUpTestCase

Open
#11,381 0 comments 0 reactions 0 assignees View on GitHub
agentic-workflows area/performance type/automation
Dominant language
C#
Stars
1k
Forks
312
Avg merge
8h 30m
Merged PRs (30d)
469

Description

> [!TIP]
> **Your pull request is ready to create! 🎉 ✅**
>
> Everything is OK—the changes have been pushed to branch `perf-assist/objectmodelconverters-fixuptestcase-benchmark-c54b6061feb1bbb0`. Please review the changes, including any protected files, before creating the pull request.
>
> **[Create the pull request](https://github.com/microsoft/testfx/compare/main...perf-assist/objectmodelconverters-fixuptestcase-benchmark-c54b6061feb1bbb0?expand=1&title=%5Bperf-improver%5D%20Add%20benchmark%20coverage%20for%20ObjectModelConverters.FixUpTestCase)**
>
> The original pull request description is below.

---

## Goal and rationale

`ObjectModelConverters.FixUpTestCase` (VSTestBridge) runs once per VSTest `TestCase` during discovery/execution — a genuine per-test hot path for every VSTest-driven run through this bridge. It was previously optimized (2026-08-13, avoiding a LINQ `Any(lambda)` delegate allocation) but had no dedicated benchmark to guard against future regressions or to serve as a baseline for further optimization.

## Approach

- Added `InternalsVisibleTo` for `MSTest.Performance.Benchmarks` to `Microsoft.Testing.Extensions.VSTestBridge.csproj` (matching the existing IVT pattern already used for `TestFramework`/`MSTest.TestAdapter`/`MSTestAdapter.PlatformServices`).
- Added a `ProjectReference` to VSTestBridge from the benchmarks project.
- Added `ObjectModelConvertersBenchmarks.cs`, measuring `FixUpTestCase` on a freshly-constructed `TestCase` per iteration (via `[IterationSetup]`, since the method mutates the instance).

## Performance evidence

Ran via `dotnet --filter "*ObjectModelConverters*" --job short` (BenchmarkDotNet, .NET 10, Linux sandbox):

| Method | Mean | Allocated |
|---|---|---|
| `FixUpTestCase` | 4.626 μs | 112 B |

This establishes a baseline; the small residual allocation comes from `TestCase.SetPropertyValue`'s dictionary-backed property store, which is out of scope for this change.

## Trade-offs

None expected — this is additive benchmark/test-infrastructure code, not a runtime behavior change. No new production dependencies.

## Reproducibility

```
./build.sh -c Release
cd test/Performance/MSTest.Performance.Benchmarks
dotnet run -c Release -f net10.0 --no-build -- --filter "*ObjectModelConverters*" --job short
```

## Test Status

- `./build.sh -c Release` succeeded (0 warnings, 0 errors).
- `Microsoft.Testing.Extensions.VSTestBridge.UnitTests` filtered to `ObjectModelConvertersTests` (`--filter "FullyQualifiedName~ObjectModelConvertersTests"`): 25/25 passed.
- `dotnet format --verify-no-changes` clean for changed files.

---

> [!NOTE]
> GitHub Actions is not permitted to create or approve pull requests in this repository.

> The changes have been pushed to branch `perf-assist/objectmodelconverters-fixuptestcase-benchmark-c54b6061feb1bbb0` and are ready to review.

To fix the permissions issue, go to **Settings** → **Actions** → **General** and enable **Allow GitHub Actions to create and approve pull requests**. See also: [gh-aw FAQ](https://github.github.com/gh-aw/reference/faq/#why-is-my-create-pull-request-workflow-failing-with-github-actions-is-not-permitted-to-create-or-approve-pull-requests)

Show patch preview (37 of 87 lines)

```diff
From b3cc00256aaf056893f1fc8c503a6198341dd022 Mon Sep 17 00:00:00 2001
X-GH-AW-Base-Commit: 00b4e2a445a42b8768fdd706e7de778e582fb034
From: "github-actions[bot]"
Date: Fri, 18 Sep 2026 13:50:28 +0000
Subject: [PATCH] Add benchmark coverage for
ObjectModelConverters.FixUpTestCase

FixUpTestCase runs once per VSTest TestCase discovered/executed through
the VSTestBridge (a genuine per-test hot path), and previously had no
dedicated benchmark despite the LINQ-allocation fix made to it earlier.

Adds InternalsVisibleTo from VSTestBridge to MSTest.Performance.Benchmarks
and a ProjectReference to VSTestBridge in the benchmarks project, plus
ObjectModelConvertersBenchmarks.cs measuring FixUpTestCase on a
freshly-constructed TestCase per iteration.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
...oft.Testing.Extensions.VSTestBridge.csproj | 1 +
.../MSTest.Performance.Benchmarks.csproj | 1 +
.../ObjectModelConvertersBenchmarks.cs | 29 +++++++++++++++++++
3 files changed, 31 insertions(+)
create mode 100644 test/Performance/MSTest.Performance.Benchmarks/ObjectModelConvertersBenchmarks.cs

diff --git a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Microsoft.Testing.Extensions.VSTestBridge.csproj b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Microsoft.Testing.Extensions.VSTestBridge.csproj
index 2cb7bf5..5239f88 100644
--- a/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Microsoft.Testing.Extensions.VSTestBridge.csproj
+++ b/src/Platform/Microsoft.Testing.Extensions.VSTestBridge/Microsoft.Testing.Extensions.VSTestBridge.csproj
@@ -22,6 +22,7 @@



+



diff --
... (truncated)
```

> [!WARNING]
>
> Firewall blocked 2 domains
>
> The following domains were blocked by the firewall during workflow execution:
>
> - `github.com`
> - `southcentralus0.in.applicationinsights.azure.com`
>
> To allow these domains, add them to the `network.allowed` list in your workflow frontmatter:
>
> ```yaml
> network:
> allowed:
> - defaults
> - "github.com"
> - "southcentralus0.in.applicationinsights.azure.com"
> ```
>
> See [Network Configuration](https://github.github.com/gh-aw/reference/network/) for more information.
>
>

> 🤖 **Automated content by GitHub Copilot.** Generated by the [Perf Improver](https://github.com/microsoft/testfx/actions/runs/35350698344/agentic_workflow) workflow. · copilot · auto · 276.2 AIC · ⌖ 9.86 AIC · ⊞ 16K · [◷]( · [◷](https://github.com/search?q=repo%3Amicrosoft%2Ftestfx+%22gh-aw-workflow-id%3A+perf-improver%22&type=pullrequests))
> Comment /perf-assist to run again
>

Add this agentic workflow to your repo

To install this agentic workflow, run

```
gh aw add githubnext/agentics/workflows/perf-improver.md@main
```

Contributor guide

Open the contributing guide

Research direction

Start with test/Performance/MSTest.Performance.Benchmarks/ObjectModelConvertersBenchmarks.cs and the project references in Microsoft.Testing.Extensions.VSTestBridge.csproj and MSTest.Performance.Benchmarks.csproj. Run the provided BenchmarkDotNet command with the ObjectModelConverters filter and verify the build, filtered ObjectModelConvertersTests, and formatting checks pass; the benchmark should report FixUpTestCase results.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
performance, testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.