Skip to content

Sustainable Code Samples and Patterns by BEN ABT

Notifications You must be signed in to change notification settings

BenjaminAbt/SustainableCode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 

Repository files navigation

🌳 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 and daily 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

.NET Condition vs Exception

.NET SHA512 Create

.NET Linq - Any vs Count

.NET List ConvertAll vs Select-ToList

.NET String Cleanup

.NET List Empty Return

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

Resources

Stars

Watchers

Forks

Languages