Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

StringFormatBenchmarks - String Formatting Performance Benchmarks in C#

YouTube Blog Newsletter All Links LinkedIn

This BenchmarkDotNet project compares the performance of string.Format(), string interpolation, and string concatenation in C#. It provides concrete benchmark data to answer the common question of which string formatting approach is fastest in .NET.

The project includes two benchmark classes: SimpleBenchmarks measures single concatenation performance at varying string lengths, while AppendInLoopBenchmarks tests loop scenarios and includes StringBuilder as a comparison baseline. Both benchmark classes test with parameter lengths of 1, 1,000, and 1,000,000 characters to show how performance scales with input size.

Built on .NET 8 with BenchmarkDotNet 0.13.11, this project gives developers real data to make informed decisions about string formatting in performance-sensitive C# code.

Getting Started

Prerequisites

  • .NET 8.0 SDK

Running the Project

cd StringFormatBenchmarks\StringFormatBenchmarks
dotnet run -c Release

Related Resources

Newsletter

If you found this useful and you want to learn more about C#, .NET, and software engineering, subscribe to the free Dev Leader Weekly newsletter:

Subscribe to Dev Leader Weekly

Connect with Dev Leader


BrandGhost

Powered by BrandGhost 👻