piharpi / SustainableCode

Sustainable Code Samples and Patterns by BEN ABT

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🌳 Sustainable Code - by BEN ABT

Sustainable applications are becoming increasingly important, because more and more energy consumption is attributable to the operations of a platform or application.

On the user side, this can be seen in the battery life of a laptop or cell phone and as a platform operator, it can be seen in the costs of compute power.

In this repository I use well-known snippets and compare them to sustainable implementations.

It's worth it!

.NET Samples

Code samples and snippets based on .NET

.NET Object Pooling with StringBuilder

.NET Less Allocations with Hyperlinq

.NET Low Allocation Log Message Generation

.NET String Generation

.NET Struct vs Class

.NET Local method hot path

.NET C# 10 String Interpolation

.NET List vs HashSet

.NET In Modifier

.NET Create Empty Collection

.NET String ToUpper vs. ToLower

.NET Enumerate List vs. IEnumerable

.NET List Count vs Count()

.NET DateTime vs. DateTimeOffset - UtcNow vs Now

.NET Linq Compiled Expressions

.NET Nullable Value Access (Pattern Matching)

.NET String Create Value Stringbuilder)

.NET Avoid List Allocations)

.NET Struct vs Class- Boxing

Energy Calculation

The energy consumption of an application itself is comparatively complex to measure and often inaccurate. Therefore, proxy measurements are mostly used: the better an application performs, the less energy is required.

The combination of the performance of the code and the energy consumption of the hardware then results in the CO2 footprint, for example.

About

Sustainable Code Samples and Patterns by BEN ABT


Languages

Language:C# 100.0%