Skip to content

Count document operations without LINQ - #10619

Draft
tobias-tengler wants to merge 1 commit into
mainfrom
tte/operation-count-without-linq
Draft

tobias-tengler wants to merge 1 commit into
mainfrom
tte/operation-count-without-linq

Conversation

@tobias-tengler

@tobias-tengler tobias-tengler commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

OperationDocumentInfo.OperationCount is evaluated on every request when the operation id is computed, and counts the operation definitions of the document with a LINQ Count.

This PR counts them with an indexed loop over the definitions.

Method Version Mean Ratio Allocated Alloc Ratio
Operation count, four definitions main 9.980 ± 0.083 ns 1.00 0 B NA
Operation count, four definitions PR 7.176 ± 0.091 ns 0.72 0 B NA

OperationDocumentInfo.OperationCount is evaluated on every request when the operation
id is computed. Count the operation definitions with an indexed loop instead of a LINQ
Count that boxes the list enumerator.
@github-actions

Copy link
Copy Markdown
Contributor

Patch coverage

87.5% of changed lines covered (14/16)

File Covered Changed Patch %
…/Execution.Abstractions/Execution/OperationDocumentInfo.cs 14 16 87.5% 🟡
Uncovered changed lines (JSON)
{
  "sha": "973ed02ad0c3e3bb128e3b3480c882e8c2847152",
  "files": [
    { "path": "src/HotChocolate/Core/src/Execution.Abstractions/Execution/OperationDocumentInfo.cs", "ranges": [[81, 82]] }
  ]
}

Project coverage: 59.0% (311536/527863 lines)

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant