bench: add RenderToString suite covering the string-returning API - #650
Merged
Conversation
The existing Render* suites write to TextWriter.Null, which measures path resolution but hides the real output costs (HTML encoding, StringBuilder- backed writes). This suite renders through the string-returning template API with clean values and escape-dense values as separate cases. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Aug 5, 2026
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Adds a
RenderToStringbenchmark suite covering the string-returning template API — the most common way the library is consumed in practice.Why
All existing
Render*suites invoke templates againstTextWriter.Null. That measures path-resolution and iteration overhead well, but a no-op writer hides the entire output side of rendering: HTML encoding and the actualStringBuilder-backed writes. During benchmarking of output-path optimizations,TextWriter.Nullproduced misleading results in both directions — it understated real-world wins (per-char writes are nearly free on a null writer) and manufactured regressions that don't exist for real writers (TextWriter's base span implementation rents/copies viaArrayPool, whichStringWriter/StreamWriternever hit).What it measures
{{#each}}list template rendered throughHandlebarsTemplate<object, object>(i.e.template(data)returning astring), which exercises the pooledReusableStringWriterpath.clean— values contain nothing that needs HTML escaping (typical data);html— values are dense with characters that must be escaped (worst case for encoder fast paths).Runtime cost: ~1 minute per full suite run (2 cases × ~30s), well within the benchmark time budget.
Baseline numbers (master, Apple M4, .NET 10)
🤖 Generated with Claude Code